public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/32408]  New: Template Parsing Error
@ 2007-06-19 20:22 chsalvia at gmail dot com
  2007-06-19 21:22 ` [Bug c++/32408] " schwab at suse dot de
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: chsalvia at gmail dot com @ 2007-06-19 20:22 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=32408


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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-19 20:22 [Bug c++/32408] New: Template Parsing Error chsalvia at gmail dot com
2007-06-19 21:22 ` [Bug c++/32408] " schwab at suse dot de
2007-06-19 22:04 ` pcarlini at suse dot de
2007-06-19 23:08 ` chsalvia at gmail dot com
2007-06-19 23:10 ` pinskia at gcc dot gnu dot org

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).