<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 - Static locals in inline functions should be hidden with -fvisibility=hidden and -fvisibility-inlines-hidden"
   href="https://bugs.llvm.org/show_bug.cgi?id=39236">39236</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Static locals in inline functions should be hidden with -fvisibility=hidden and -fvisibility-inlines-hidden
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

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

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>hans@chromium.org, inouehrs@jp.ibm.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This is a bug in the fix to <a href="https://llvm.org/pr37595">https://llvm.org/pr37595</a>, or r340386.

We encountered it in Chromium here: <a href="https://crbug.com/891992#c20">https://crbug.com/891992#c20</a>

This probably isn't too hard to fix.

Pasting Hans's reproducer below:

Yes, it seems Clang and GCC behave differently here:

inline int foo() {
  static int x;
  return x++;
}

int use() { return foo(); }


$ g++ -fvisibility=hidden -fvisibility-inlines-hidden -c /tmp/a.cc && objdump
-t a.o

a.o:     file format elf64-x86-64

SYMBOL TABLE:
0000000000000000 l    df *ABS*  0000000000000000 a.cc
0000000000000000 l    d  .text  0000000000000000 .text
0000000000000000 l    d  .data  0000000000000000 .data
0000000000000000 l    d  .bss   0000000000000000 .bss
0000000000000000 l    d  .bss._ZZ3foovE1x       0000000000000000
.bss._ZZ3foovE1x
0000000000000000 l    d  .text._Z3foov  0000000000000000 .text._Z3foov
0000000000000000 l    d  .note.GNU-stack        0000000000000000
.note.GNU-stack
0000000000000000 l    d  .eh_frame      0000000000000000 .eh_frame
0000000000000000 l    d  .<a href="show_bug.cgi?id=39236#c0000000000000000">comment       0000000000000000</a> .comment
0000000000000000 l    d  .group 0000000000000000 .group
0000000000000000 l    d  .group 0000000000000000 .group
0000000000000000 u     O .bss._ZZ3foovE1x       0000000000000004 .hidden
_ZZ3foovE1x   <---- foo()::x is hidden
0000000000000000  w    F .text._Z3foov  0000000000000015 .hidden _Z3foov
0000000000000000 g     F .text  000000000000000b .hidden _Z3usev


$ clang++ -fvisibility=hidden -fvisibility-inlines-hidden -c /tmp/a.cc &&
objdump -t a.o

a.o:     file format elf64-x86-64

SYMBOL TABLE:
0000000000000000 l    df *ABS*  0000000000000000 a.cc
0000000000000000 l    d  .text  0000000000000000 .text
0000000000000000 l    d  .text._Z3foov  0000000000000000 .text._Z3foov
0000000000000000  w    F .text._Z3foov  0000000000000019 .hidden _Z3foov
0000000000000000 g     F .text  000000000000000b .hidden _Z3usev
0000000000000000  w    O .bss._ZZ3foovE1x       0000000000000004 _ZZ3foovE1x   
<----- foo()::x is not hidden</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>