[llvm-bugs] [Bug 30800] New: static const class variables in unnamed namespace have external linkage

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Oct 26 13:12:30 PDT 2016


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

            Bug ID: 30800
           Summary: static const class variables in unnamed namespace have
                    external linkage
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: timshen91 at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

namespace {
  struct A { static const int foo = 3; };
  const int bar = 4;
}

const int &Foo() {
  return A::foo;
}

const int &Bar() {
  return bar;
}

In this example bar has internal linkage:
@_ZN12_GLOBAL__N_1L3barE = internal constant i32 4, align 4

but A::foo has external linkage:
@_ZN12_GLOBAL__N_11A3fooE = external constant i32, align 4

A::foo should have internal linkage and the initializer.

-- 
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/20161026/c25a56d2/attachment.html>


More information about the llvm-bugs mailing list