This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
Suppose a primary template template <class T> class A; and a sepcialization: template <class T> class A<volatile T>; When instantiated with a plain function type (that is, not a pointer or reference to function), the compiler picks the specialization for volatile. (It gives warnings that volatile qualifiers are ignored). Release: 3.2 Environment: System: SunOS ford.osl.iu.edu 5.8 Generic_108528-15 sun4u sparc SUNW,Sun-Blade-100 Architecture: sun4 host: sparc-sun-solaris2.8 build: sparc-sun-solaris2.8 target: sparc-sun-solaris2.8 configured with: ../dist/configure --prefix=/l/gcc320 --enable-language=c,c++,f77,java How-To-Repeat: This program demonstrates the error: #include <iostream> template <class T> class A { public: static void foo () { std::cout << "Not volatile"; } }; template <class T> class A<volatile T> { public: static void foo () { std::cout << "Volatile"; } }; template <class T> void x(T& t) { A<T>::foo(); // T here should be a plain function type int()() (not a pointer, not a ref) // The compiler (3.20) picks the specializatoin for A<volatile T> ??? } int bar() {}; int main() { x(bar); }; // ----------------------- This the output from the compiler: /l/gcc320/bin/g++ -I/u/jajarvi/boost testi.cpp testi.cpp: In instantiation of `A<int ()()>': testi.cpp:15: instantiated from `void x(T&) [with T = int ()()]' testi.cpp:24: instantiated from here testi.cpp:8: warning: ignoring `volatile' qualifiers on `int ()()' testi.cpp:8: warning: ignoring `volatile' qualifiers on `int ()()' And when the program is run, it outputs "Volatile".
State-Changed-From-To: open->analyzed State-Changed-Why: This used to work with 2.95, so I mark it as a regression. However, note that it is fixed in 3.3CVS already.
Responsible-Changed-From-To: unassigned->lerdsuwa Responsible-Changed-Why: Will look at it. Appear to be related to PR 8503.
Responsible-Changed-From-To: lerdsuwa->nathan Responsible-Changed-Why: Same problem as PR8503.
State-Changed-From-To: analyzed->closed State-Changed-Why: 2002-12-26 Nathan Sidwell <nathan@codesourcery.com> PR c++/8503 Remove DR 295 implementation. * pt.c (check_cv_quals_for_unify): Disable function & method cases. * tree.c (cp_build_qualified_type_real): Likewise. Don't warn about ignoring volatile qualifiers.