[LLVMbugs] [Bug 23136] New: clang seems to silently ignore the weak attribute (mingw)
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Apr 6 11:19:18 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=23136
Bug ID: 23136
Summary: clang seems to silently ignore the weak attribute
(mingw)
Product: clang
Version: trunk
Hardware: PC
OS: Windows XP
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: t.poechtrager at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
$ cat test.cpp
#include <malloc.h>
#include <stdlib.h>
#include <stddef.h>
#ifdef WEAK
#undef WEAK
#define WEAK __attribute__((weak))
#else
#define WEAK
#endif
WEAK void *operator new(size_t size) throw()
{
void *p = malloc(size);
if(!p) abort();
return p;
}
WEAK void *operator new[](size_t size) throw()
{
void *p = malloc(size);
if(!p) abort();
return p;
}
WEAK void operator delete(void *p) throw() { if(p) free(p); }
WEAK void operator delete(void *p, size_t) throw() { if(p) free(p); }
WEAK void operator delete[](void *p) throw() { if(p) free(p); }
WEAK void operator delete[](void *p, size_t) throw() { if(p) free(p); }
WEAK int main()
{
new char[100];
}
$ i686-w64-mingw32-clang++ test.cpp -Weverything -Wno-missing-prototypes -c -o
1.o
$ i686-w64-mingw32-clang++ test.cpp -Weverything -Wno-missing-prototypes -c -o
2.o -DWEAK
$ LC_ALL=C i686-w64-mingw32-clang++ 1.o 2.o
2.o:(.text+0x0): multiple definition of `operator new(unsigned int)'
1.o:(.text+0x0): first defined here
2.o:(.text+0x40): multiple definition of `operator new[](unsigned int)'
1.o:(.text+0x40): first defined here
2.o:(.text+0x80): multiple definition of `operator delete(void*)'
1.o:(.text+0x80): first defined here
2.o:(.text+0xb0): multiple definition of `operator delete(void*, unsigned int)'
1.o:(.text+0xb0): first defined here
2.o:(.text+0xe0): multiple definition of `operator delete[](void*)'
1.o:(.text+0xe0): first defined here
2.o:(.text+0x110): multiple definition of `operator delete[](void*, unsigned
int)'
1.o:(.text+0x110): first defined here
2.o:(.text+0x140): multiple definition of `main'
1.o:(.text+0x140): first defined here
collect2: error: ld returned 1 exit status
clang-3.7: error: linker (via gcc) command failed with exit code 1 (use -v to
see invocation)
mingw-g++ handles this correctly:
$ i686-w64-mingw32-g++ test.cpp -c -o 1.o
$ i686-w64-mingw32-g++ test.cpp -c -o 2.o -DWEAK
$ LC_ALL=C i686-w64-mingw32-g++ 1.o 2.o && echo $?
0
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150406/295e1c84/attachment.html>
More information about the llvm-bugs
mailing list