http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58203

            Bug ID: 58203
           Summary: memset/memcpy are discarded with -flto
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kukyakya at gmail dot com

It might be a duplicate of bug 51205 but it's happening again.

[test.cpp]
typedef void (*action_t)(const unsigned char*);

extern "C" void _start(action_t action)
{
  const unsigned char foo[256] = {};

  action(foo);
}

typedef __SIZE_TYPE__ size_t;

extern "C"
void*
//__attribute__((externally_visible)) // Workaround
memset(void* dst, int c, size_t len)
{
  unsigned char * d = (unsigned char*)dst;

  while(len--)
    *d++ = c;

  return dst;
}

[error]
$ arm-none-linux-gnueabi-g++ -fno-exceptions -nostartfiles -static -nostdlib
-nodefaultlibs -flto test.cpp -o test
`memset' referenced in section `.text' of /tmp/cc7ooAE0.ltrans0.ltrans.o:
defined in discarded section `.text' of /tmp/ccVDnjy6.o (symbol from plugin)
collect2: error: ld returned 1 exit status

[versions]
arm-none-linux-gnueabi-g++ --version : 4.8.1
arm-none-linux-gnueabi-ld --version : 2.23.2

Reply via email to