Hi, First of all this is my first bug report to GNU GCC so please bare with me.
The issue I having is with typedef assisted declarations of class/struct member functions. It seems to me that cv-qualifiers on function typedef's are treated inconsistantly depending on the scope of the typedef. The below code demonstrates the problem: with NS_SCOPE defined the code compiles fine with "-Wall -Wextra -pedantic" on 4.3.2 but when NS_SCOPE is undefined, the const qualifier is ignored with "error: ignoring ‘const’ qualifiers added to function type". To me this seems completely inconsistent and there is no explaination as to why the qualifer is ignored. ---snip--- #include <iostream> #ifdef NS_SCOPE typedef void (function_type)(int) const; #endif template <typename T> struct S1 { #ifndef NS_SCOPE typedef void (function_type)(int) const; #endif }; struct S2: public S1<int> { virtual function_type f = 0; }; struct S3: public S2 { void f (int i) const { std::cout << "Hello world: " << i << std::endl; } }; int main() { S3 s; s.f(5); } ---snip--- I did find a C++ defect report that may be relevent, but to be honest, i'm not certain what is going on with regard to the standard here http://open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#295 I hope this can be resolved because it will allow for some really groovy template generated interfaces. Visual Studio 2005 (the only other compiler I have to hand) seems to compile this code without NS_SCOPE defined, but I'm uncertain how to thoroughly test this there. -- Summary: CV-qualifiers on function typedef's are inconsistently accepted depending on typedef scope Product: gcc Version: 4.3.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: andrew at nelless dot net GCC host triplet: x86_64 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37806