PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12577 Summary: typeof does not qualify as unqualified-id in certain contexts Product: gcc Version: 3.4 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gabor dot greif at lucent dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: *-*-* GCC host triplet: *-*-* GCC target triplet: *-*-* Compile this snippet: ----------------------------- struct bar { void setfoobar(int); int getfoobar(void) const; static int (bar::* const getter1)(void) const; }; template struct foo { static void (S::* const setter)(T); static T (S::* const getter)(void) const; }; template <> void (bar::* const foo::setter)(int) = &bar::setfoobar; template T* JustAPointer(void); template <> void (bar::* const foo()->getfoobar())>::setter)( __typeof__(JustAPointer()->getfoobar())) = &bar::setfoobar; __typeof__(JustAPointer()->getfoobar()) bar::getfoobar() const { return 42; } //int (bar::* const bar::getter1)(void) const = &bar::getfoobar; //(__typeof__(JustAPointer()->getfoobar())) (bar::* const bar::getter1)(void) const = &bar::getfoobar; //typename __typeof__(JustAPointer()->getfoobar()) (bar::* const bar::getter1)(void) const = &bar::getfoobar; __typeof__(JustAPointer()->getfoobar()) (bar::* const bar::getter1)(void) const = &bar::getfoobar; template <> //__typeof__(JustAPointer()->getfoobar()) (bar::* const foo()->getfoobar())>::setter)(void) typeof(JustAPointer()->getfoobar()) (bar::* const foo()->getfoobar())>::setter)(void) = &bar::getfoobar; ---------------------------­------- You get numerous error. I go thru them one by one: foobar.cpp:25: error: duplicate initialization of foo::setter foobar.cpp:25: error: redefinition of `void (bar::*const foo::setter)(int)' ----> this is expected, it shows that typeof works as template argument. foobar.cpp:18: error: `void (bar::*const foo::setter)(int)' previously declared here ----> dito foobar.cpp:35: error: expected unqualified-id ----> I'd expect that G++ accepts this. Previous versions certainly did. So this is a regression with the new C++ parser. foobar.cpp:35: error: expected primary-expression foobar.cpp:35: error: `JustAPointer() [with T = bar]()->bar::getfoobar() const()' cannot be used as a function foobar.cpp:35: error: expected primary-expression foobar.cpp:35: error: expected unqualified-id foobar.cpp:35: error: expected `,' or `;' -----> I guess this is further junk because of the above. foobar.cpp:39: error: `JustAPointer() [with T = bar]()->bar::getfoobar() const()' cannot be used as a function foobar.cpp:39: error: expected unqualified-id foobar.cpp:39: error: expected primary-expression foobar.cpp:39: error: expected primary-expression foobar.cpp:39: error: `JustAPointer() [with T = bar]()->bar::getfoobar() const()' cannot be used as a function foobar.cpp:39: error: expected primary-expression foobar.cpp:40: error: expected unqualified-id -----> similarly. This is the actual problem I encountered in our cource code. Also, this is the most omportant one to fix! :-) Thanks in advance, Gabor