public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/32409]  New: Template Parsing Error
@ 2007-06-19 20:29 chsalvia at gmail dot com
  2007-06-19 21:22 ` [Bug c++/32409] " schwab at suse dot de
  0 siblings, 1 reply; 2+ messages in thread
From: chsalvia at gmail dot com @ 2007-06-19 20:29 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1588 bytes --]

GCC may have a defective template parsing routine which seems to mistake the
'<' token in an expression for the beginning of a template argument.  The error
only seems to happen when a templated function evaluates a member of a
templated class or struct with a '<' symbol.

Here is a simple code snippet that reproduces the problem:

template <class T>
struct templated_struct 
{
        int count;
};

template <class T>
int template_func()
{
        templated_struct<T> s;
        if (s.count < 0) return 0;
        return 0;
}

int main()
{
        template_func<int> ();
        return 0;
}

The compiler generates the follow error message when trying to compile the
above code:

test4.cc: In function ‘int template_func()’:
test4.cc:16: error: parse error in template argument list
test4.cc: In function ‘int template_func() [with T = int]’:
test4.cc:22:   instantiated from here
test4.cc:16: error: ‘count’ is not a member template function

Note that the above code compiles just fine if you replace the '<' token in the
IF statement with an '>' or an '==', thus demonstrating that GCC seems to be
confusing the '<' token for a template argument.

A temporary workaround is to put a set of parenthesis around s.count.


-- 
           Summary: Template Parsing Error
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: chsalvia at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32409


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/32409] Template Parsing Error
  2007-06-19 20:29 [Bug c++/32409] New: Template Parsing Error chsalvia at gmail dot com
@ 2007-06-19 21:22 ` schwab at suse dot de
  0 siblings, 0 replies; 2+ messages in thread
From: schwab at suse dot de @ 2007-06-19 21:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from schwab at suse dot de  2007-06-19 21:22 -------


*** This bug has been marked as a duplicate of 32408 ***


-- 

schwab at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32409


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-06-19 21:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-19 20:29 [Bug c++/32409] New: Template Parsing Error chsalvia at gmail dot com
2007-06-19 21:22 ` [Bug c++/32409] " schwab at suse dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).