[LLVMbugs] [Bug 12005] New: explicit instantiation doesn't emit variable is non-ODR-used earlier

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Feb 14 15:01:26 PST 2012


http://llvm.org/bugs/show_bug.cgi?id=12005

             Bug #: 12005
           Summary: explicit instantiation doesn't emit variable is
                    non-ODR-used earlier
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu,
                    sharparrow1 at yahoo.com
    Classification: Unclassified


This testcase demonstrates a problem:

  void f(int);

  template <typename T>
  struct A {
    void g() { f(k); }
    static const int k;
  };

  template <typename T> const int A<T>::k = -1;

  template struct A<int>;

where we fail to emit 'A<int>::k' because it was used -- but not ODR-used --
earlier in the body of g.

nlewycky at ducttape:~$ g++ x.cc -c; nm x.o
                 U _Z1fi
0000000000000000 W _ZN1AIiE1gEv
0000000000000000 V _ZN1AIiE1kE
                 U __gxx_personality_v0
nlewycky at ducttape:~$ llvm/Debug+Asserts/bin/clang++ x.cc -c; nm x.o
                 U _Z1fi
0000000000000000 W _ZN1AIiE1gEv

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list