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

            Bug ID: 21923
           Summary: fail to diagnose use of member in static method, crash
                    later in codegen
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

Testcase:

template <typename T>
struct Base {
  int member;
};

template <typename T>
struct Derived : public Base<T> {
  static void Test();
  using Base<T>::member;
};

template <typename T>
void Derived<T>::Test() {
  member;  // error: may not access member in static method.
}

template class Derived<int>;

GCC says:

$ g++ -std=gnu++11 b18754991.cc
b18754991.cc: In instantiation of ‘static void Derived<T>::Test() [with T =
int]’:
b18754991.cc:17:16:   required from here
b18754991.cc:3:7: error: invalid use of member ‘Base<int>::member’ in static
member function
   int member;
       ^
b18754991.cc:14:3: error: from this location
   member;  // error: may not access member in static method.
   ^

Clang finds no error here, then crashes in codegen with:

$ clang -cc1 -std=gnu++11 b18754991.cc -emit-llvm-only
b18754991.cc:14:3: warning: expression result unused
  member;  // error: may not access member in static method.
  ^~~~~~
b18754991.cc:17:16: note: in instantiation of member function
'Derived<int>::Test' requested here
template class Derived<int>;
               ^
Unhandled DeclRefExpr
UNREACHABLE executed at CGExpr.cpp:2010!
[...]

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to