Bug 27732 - [4.0 Regression] Parentheses elicit spurious error: "missing '>' to terminate the template argument list"
Summary: [4.0 Regression] Parentheses elicit spurious error: "missing '>' to terminate...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2006-05-22 20:08 UTC by James Widman
Modified: 2007-02-03 17:22 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.4
Known to fail: 3.4.2 4.0.2
Last reconfirmed: 2006-05-22 22:46:05


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Widman 2006-05-22 20:08:16 UTC
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?
Comment 1 Wolfgang Bangerth 2006-05-22 22:46:05 UTC
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.
Comment 2 James Widman 2006-05-23 15:10:33 UTC
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

Comment 3 Mark Mitchell 2006-10-16 23:25:22 UTC
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
Comment 4 Gabriel Dos Reis 2007-02-03 17:22:19 UTC
Fixed in GCC-4.1.0.
Won't fix in GCC-4.0.x.