Bug 20308 - parser thinks something is a start of a template-id when it is just less than
Summary: parser thinks something is a start of a template-id when it is just less than
Status: RESOLVED DUPLICATE of bug 10200
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
: 24939 46839 (view as bug list)
Depends on: 11814
Blocks:
  Show dependency treegraph
 
Reported: 2005-03-03 21:46 UTC by Ivan Godard
Modified: 2010-12-07 17:24 UTC (History)
7 users (show)

See Also:
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


Attachments
Compiler output (-v -save-temps) (694 bytes, application/octet-stream)
2005-03-03 21:47 UTC, Ivan Godard
Details
Source code (-save-temps) (compressed) (139.83 KB, application/x-gzip)
2005-03-03 21:48 UTC, Ivan Godard
Details

Note You need to log in before you can comment on or make changes to this bug.
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. ***