public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16713] New: call of template member function rejected
@ 2004-07-26 10:54 marco at technoboredom dot net
  2004-07-26 11:26 ` [Bug c++/16713] " marco at technoboredom dot net
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: marco at technoboredom dot net @ 2004-07-26 10:54 UTC (permalink / raw)
  To: gcc-bugs

The following code compiles on Intel Compiler for Linux 8.0 and Microsoft Visual
C++ 7.1, but is rejected by gcc: 

/* BEGIN */
template<class T>
void fail1() 
{
  T::f<T>(); 
}
/* END */
results in the error message:

marco@gontscharow:~/tmp/gcc$ /opt/gcc-3.4.1/bin/g++ -c a.cc
a.cc: In function `void fail1()':
a.cc:5: error: expected primary-expression before '>' token
a.cc:5: error: expected primary-expression before ')' token

marco@gontscharow:~/tmp/gcc$ /opt/gcc-3.4.1/bin/g++ -v
Reading specs from /opt/gcc-3.4.1/lib/gcc/i686-pc-linux-gnu/3.4.1/specs
Configured with: /usr/local/src/gcc/source/gcc-3.4.1/configure -v
--prefix=/opt/gcc-3.4.1 --enable-shared --disable-checking --verbose
--with-gnu-as --with-gnu-ld --enable-__cta_atexit --enable-threads=posix
Thread model: posix
gcc version 3.4.1

Suspecting this as a parsing problem, I found this possible variation:

/* BEGIN */
template<class T>
void fail2() 
{
  T::f<0,0>(0); 
}

class X
{
public:
  template<int x, int y> void f(int); 
}; 
int x() 
{
  fail2<X>();
}
/*END*/

This results in the following message: 
marco@gontscharow:~/tmp/gcc$ /opt/gcc-3.4.1/bin/g++ -c a.cc
a.cc: In function `void fail2() [with T = X]':
a.cc:14:   instantiated from here
a.cc:4: error: invalid operands of types `<unknown type>' and `int' to binary
`operator<'

I therefore guess, that gcc parses: 
  T::f<0,0>(0); 
as 
  (T::f<0)  , (0>(0))

And fails in: 
  T::f<T>(); 
Because it thinks: 
  (T::f<T) >();

-- 
           Summary: call of template member function rejected
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: marco at technoboredom dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i486-slackware-linux
  GCC host triplet: i486-slackware-linux
GCC target triplet: i486-slackware-linux


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


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

* [Bug c++/16713] call of template member function rejected
  2004-07-26 10:54 [Bug c++/16713] New: call of template member function rejected marco at technoboredom dot net
@ 2004-07-26 11:26 ` marco at technoboredom dot net
  2004-07-26 13:30 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: marco at technoboredom dot net @ 2004-07-26 11:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From marco at technoboredom dot net  2004-07-26 11:26 -------
After getting suspicious on the validity of the code (though accepted by other
compilers), I found that the correct, insane syntax is: 

template<class T>
void fail() 
{
  T::template fail<T>(); 
}

My regrets. 


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


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


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

* [Bug c++/16713] call of template member function rejected
  2004-07-26 10:54 [Bug c++/16713] New: call of template member function rejected marco at technoboredom dot net
  2004-07-26 11:26 ` [Bug c++/16713] " marco at technoboredom dot net
@ 2004-07-26 13:30 ` pinskia at gcc dot gnu dot org
  2004-11-05 19:28 ` bangerth at dealii dot org
  2004-11-05 19:32 ` bangerth at dealii dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-26 13:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-26 13:30 -------
Yes you could have found it easier if you had read the release notes first at <http://gcc.gnu.org/
gcc-3.4/changes.html>, just like your other bug which it tells you how to fix your code.

-- 


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


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

* [Bug c++/16713] call of template member function rejected
  2004-07-26 10:54 [Bug c++/16713] New: call of template member function rejected marco at technoboredom dot net
  2004-07-26 11:26 ` [Bug c++/16713] " marco at technoboredom dot net
  2004-07-26 13:30 ` pinskia at gcc dot gnu dot org
@ 2004-11-05 19:28 ` bangerth at dealii dot org
  2004-11-05 19:32 ` bangerth at dealii dot org
  3 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2004-11-05 19:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-11-05 19:27 -------
These are all duplicates of PR 15552 

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


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


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

* [Bug c++/16713] call of template member function rejected
  2004-07-26 10:54 [Bug c++/16713] New: call of template member function rejected marco at technoboredom dot net
                   ` (2 preceding siblings ...)
  2004-11-05 19:28 ` bangerth at dealii dot org
@ 2004-11-05 19:32 ` bangerth at dealii dot org
  3 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2004-11-05 19:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-11-05 19:32 -------
Duplicate of PR 15552. 

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

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


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


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

end of thread, other threads:[~2004-11-05 19:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-26 10:54 [Bug c++/16713] New: call of template member function rejected marco at technoboredom dot net
2004-07-26 11:26 ` [Bug c++/16713] " marco at technoboredom dot net
2004-07-26 13:30 ` pinskia at gcc dot gnu dot org
2004-11-05 19:28 ` bangerth at dealii dot org
2004-11-05 19:32 ` bangerth at dealii 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).