<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - clang seems to silently ignore the weak attribute (mingw)"
   href="https://llvm.org/bugs/show_bug.cgi?id=23136">23136</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang seems to silently ignore the weak attribute (mingw)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows XP
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>t.poechtrager@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ 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</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>