I get spurious errors from g++ in the following cases: // case 1: int m; template< int* p> struct A { }; template<> struct A<&(m)>; // case 2: int m; template< int* p> struct A { }; template<> struct A<(&m)>; Just a guess: is there something about the parse of '(' that gums up the works?
Confirmed. I guess the workaround is to simply not use the parenthesis. Nevertheless, this is a regression introduced with the new parser in 3.4.0. W.
By the way: whoever tackles this may also want to take a look at: template< int* p> struct A { }; template<> struct A<(int*)0>; ...which was made permissible by the recently-adopted wording that was proposed for Defect Report 354: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2006/n1998.html#354
James -- Case #1 in Comment #1 is accepted by current G++ 4.1 and mainline branches. I do not believe Case #2 is valid, as the standard says that a non-type template argument may be: the address of an object or function with external linkage, includ- ing function templates and function template-ids but excluding non- static class members, expressed as & id-expression Thus, the parentheses make this case invalid. Admittedly, that's pedantic, but I think that's what the standard says. Comment #3 is a separate enhancement request, and should be refiled separately. Thanks, -- Mark
Fixed in GCC-4.1.0. Won't fix in GCC-4.0.x.