[LLVMbugs] [Bug 7079] New: Clang does not mark declarations used in non-dependent types as referenced

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu May 6 17:09:46 PDT 2010


           Summary: Clang does not mark declarations used in non-dependent
                    types as referenced
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: dgregor at apple.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
            Blocks: 6023

When we're parsing a template, we don't "mark" declarations we reference as
referenced, since we intend to do that when the template is instantiated.
However, if those declarations are only referenced from a non-dependent type,
we don't rebuild the type so we don't end up marking the declarations as
referenced at instantiation time. The example below (distilled from the Boost
concept-checking library) illustrates how one can use template arguments in a
non-dependent type to trigger instantiation... but Clang doesn't do the

We have the same issue with non-dependent expressions used in default
arguments; see http://llvm.org/bugs/show_bug.cgi?id=5810 .

terfin:clang dgregor$ cat t.cpp 
template<typename T>
struct X1 {
  static void member() { T* x = 1; }

template<void(*)()> struct instantiate { };

template<typename T>
struct X2 {
  typedef instantiate<&X1<int>::member> i;

X2<int> x;
terfin:clang dgregor$ clang++ -fsyntax-only t.cpp 
terfin:clang dgregor$ g++ -fsyntax-only t.cpp 
t.cpp: In static member function ‘static void X1<T>::member() [with T = int]’:
t.cpp:3:   instantiated from here
t.cpp:3: error: invalid conversion from ‘int’ to ‘int*’

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