<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - operator new(size_t) can't have hidden visibility"
   href="https://bugs.llvm.org/show_bug.cgi?id=33473">33473</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>operator new(size_t) can't have hidden visibility
          </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>Linux
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>thomasanderson@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Compile the attached test.cpp with clang 5.0.0:
$ clang++ -fvisibility=hidden -nostdinc++ -std=c++11 -c test.cpp -o test.o

-fvisibility=hidden should make all symbols hidden, but operator new is not:

$ objdump -t test.o | grep _Znwm
0000000000000000 g     F .text  000000000000000f _Znwm
000000000000000f g     F .text  0000000000000013 .hidden _ZnwmRK9nothrow_t

Adding 'attribute((visibility("hidden")))' on operator new only raises an
error:

test.cpp:4:16: error: visibility does not match previous declaration
__attribute__((visibility("hidden")))
               ^
note: previous attribute is here
1 error generated.


I was told that this behavior is determined by a built-in declaration that is
added here:
<a href="http://llvm-cs.pcc.me.uk/tools/clang/lib/Sema/SemaExprCXX.cpp#2668">http://llvm-cs.pcc.me.uk/tools/clang/lib/Sema/SemaExprCXX.cpp#2668</a></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>