Bug 20308

Summary: parser thinks something is a start of a template-id when it is just less than
Product: gcc Reporter: Ivan Godard <igodard>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: chsalvia, fang, foehst, gcc-bugs, igodard, pinskia, reichelt
Priority: P2 Keywords: rejects-valid
Version: 3.4.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: 3.3.3 3.4.0 4.0.0 2.95.3 3.2.3 Last reconfirmed: 2005-11-02 02:04:28
Bug Depends on: 11814    
Bug Blocks:    
Attachments: Compiler output (-v -save-temps)
Source code (-save-temps) (compressed)

Description Ivan Godard 2005-03-03 21:46:38 UTC
In the attached code, the parser gets confused by a use of operator< in the body 
of a function template. If the operator is changed (to ">" or "==" for example) 
the code compiles. I've not been able to figure out why it thinks it's in a 
constant expression. Changing the variable names involved doesn't make a 
difference, so it doesn't see to be a consequence of name clashes.

Ivan
Comment 1 Ivan Godard 2005-03-03 21:47:44 UTC
Created attachment 8321 [details]
Compiler output (-v -save-temps)
Comment 2 Ivan Godard 2005-03-03 21:48:30 UTC
Created attachment 8322 [details]
Source code (-save-temps) (compressed)
Comment 3 Andrew Pinski 2005-03-03 23:25:21 UTC
Hmm, this is the reduced testcase (but I don't know if this is invalid as Comeau also rejects it but I think 
it is valid):
template<typename> int nick(int e);
template<int> struct operation{int nick;};
template<int s>
bool alphaMnemonic(const operation<s>& o1, const operation<s>& o2)
{
  return o1.nick < o2.nick;
}

If nick was not a template or not declated we accept it, if alphaMnemonic is not a template we accept it.
I think we have a name lookup problem really.  if we want o1.nick as a template we need the template 
keyword.  This is not a regression if this is valid code, I really think it is.  ICC 8.0 accepts it.
Comment 4 Wolfgang Bangerth 2005-07-23 21:29:42 UTC
There is another PR about exactly this problem somewhere. 
Comment 5 Ivan Godard 2005-07-24 00:29:05 UTC
Sorry, I'll try to be more original in my PRs :-)
Comment 6 Wolfgang Bangerth 2005-07-24 04:51:33 UTC
Don't worry, I'm just trying to tighten the net of PRs somehow -- if someone 
comes around to fix this PR, she might take a little more time than I have 
right now to find that duplicate PR... 
Comment 7 Andrew Pinski 2005-11-19 18:34:50 UTC
*** Bug 24939 has been marked as a duplicate of this bug. ***
Comment 8 Andrew Pinski 2008-09-20 02:56:40 UTC

*** This bug has been marked as a duplicate of 10200 ***
Comment 9 Andrew Pinski 2010-12-07 17:24:19 UTC
*** Bug 46839 has been marked as a duplicate of this bug. ***