The following code compiles ok with -DOK1 or -DOK2. The default case generate the following error which seems wrong.
gmo2.cc: In member function 'int Packer<T>::foo()': gmo2.cc:17:29: error: request for member 'size' in 'Packer::var', which is of non-class type 'const std::string&' #include <string> template <typename T> struct base { const std::string& var; }; template<typename T> struct Packer : public base<T> { int foo() { #ifdef OK1 return Packer<T>::size; #elif defined (OK2) return base<T>::var.size(); #else return Packer<T>::var.size(); #endif } const std::string& var; const int& size; }; -- Summary: Parsing error related to qualified name id Product: gcc Version: 4.5.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: davidxl at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41038