[llvm-bugs] [Bug 37595] New: -fvisibility-inlines-hidden marks static local variables as hidden when it shouldn't

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 25 14:43:12 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37595

            Bug ID: 37595
           Summary: -fvisibility-inlines-hidden marks static local
                    variables as hidden when it shouldn't
           Product: clang
           Version: 3.2
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: redbeard0531 at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

At the very least this is a scary undocumented difference from that flag's
meaning under gcc. Quoting the gcc man page for that flag (emphasis mine): The
behavior of this switch is not quite the same as marking the methods as hidden
directly, because ***it does not affect static variables local to the
function*** or cause the compiler to deduce that the function is defined in
only one shared object.

https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fvisibility-inlines-hidden
only says "Give inline C++ member functions default visibility by default"
which doesn't seem to accurately describe the behavior.

Here is a simple example that shows the issue: https://godbolt.org/g/63FiwD 

inline int* test() {
    static int staticVar;
    return &staticVar;
}
auto force = test();

The problematic line is in the generated ASM is ".hidden test()::staticVar".
That is only generated with clang with -fvisibility-inlines-hidden. gcc does
not add that line to the output. I walked back the versions on godbolt and it
looks like this was introduced between 3.1 and 3.2.

-- 
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/20180525/92dfb8ca/attachment.html>


More information about the llvm-bugs mailing list