public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/9298: [3.4 regression] [new parser] ICE with function-pointer-type template args
@ 2003-01-15 20:46 Volker Reichelt
  0 siblings, 0 replies; 6+ messages in thread
From: Volker Reichelt @ 2003-01-15 20:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/9298; it has been noted by GNATS.

From: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
To: bangerth@ticam.utexas.edu
Cc: gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Subject: Re: c++/9298: [3.4 regression] [new parser] ICE with function-pointer-type template args
Date: Wed, 15 Jan 2003 22:39:56 +0100

 Hi Wolfgang,
 
 sorry for the confusion, I was *quite* wrong.
 Let's have another look at the code:
 
 The declaration of foo as a static template function is of course legal.
 But I disagree with you when you say
 
 > It's illegal, though, to use its address as a template parameter!
 
 Why should it be illegal? You can use the address of a static variable as
 a template parameter, too:
 
 ------------snip here-------------
 int i;
 template <int*> void foo() {}
 template void foo<&i> ();
 ----------------------------------
 
 You're right, there's only one bug in the following line:
 
 > template int CPU::dispatch<&template foo<2> > ();
                               ^^^^^^^^
 
 And then, there's one more bug in the whole file:
 We only have declarations for "foo" and "dispatch", but we need
 definitions for the explicit instantiation of dispatch and its
 template parameter.
 
 Given that, the following code should compile IMHO (the EDG front-end
 thinks so, too):
 
 ----------------------snip here-------------------
 struct A
 {
     typedef void (*pfun)();
 
     template <pfun> static void bar() {}
 };
 
 template <int> static void foo() {}
 
 template void A::bar< &foo<0> >();
 ----------------------snip here-------------------
 
 Alas, each gcc version since 2.95.x rejects the code with a message similar to
 
 bug.cc:10: `&foo<0>' is not a valid template argument
 bug.cc:10: template-id `bar<(&foo<0>)>' for `void A::bar()' does not match any 
    template declaration
 
 (That's probably why I ended up changing random things in the code to make
 it compile and came up with the bogus errors from my first message.)
 
 That leaves us with an additional rejects-legal bug.
 I'll open an additional PR for that one, if you agree.
 
 Regards,
 Volker
 
 


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

* Re: c++/9298: [3.4 regression] [new parser] ICE with function-pointer-type template args
@ 2003-01-22 22:25 mmitchel
  0 siblings, 0 replies; 6+ messages in thread
From: mmitchel @ 2003-01-22 22:25 UTC (permalink / raw)
  To: bangerth, gcc-bugs, gcc-prs, nobody

Synopsis: [3.4 regression] [new parser] ICE with function-pointer-type template args

State-Changed-From-To: analyzed->closed
State-Changed-By: mmitchel
State-Changed-When: Wed Jan 22 22:25:48 2003
State-Changed-Why:
    Fixed in GCC 3.4.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9298


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

* Re: c++/9298: [3.4 regression] [new parser] ICE with function-pointer-type template args
@ 2003-01-15 22:16 Volker Reichelt
  0 siblings, 0 replies; 6+ messages in thread
From: Volker Reichelt @ 2003-01-15 22:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/9298; it has been noted by GNATS.

From: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
To: bangerth@ticam.utexas.edu
Cc: gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Subject: Re: c++/9298: [3.4 regression] [new parser] ICE with function-pointer-type template args
Date: Thu, 16 Jan 2003 00:12:15 +0100

 On 15 Jan, Wolfgang Bangerth wrote:
 
 > Values for pointer- or reference-type template arguments need to have 
 > _external_ linkage. "int i" does have that, "static void foo()" doesn't.
 
 Argghh! Sorry again! You're right, of course. ISO-standard 14.3.2.
 
 Regards,
 Volker
 
 


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

* Re: c++/9298: [3.4 regression] [new parser] ICE with function-pointer-type template args
@ 2003-01-15 21:36 Wolfgang Bangerth
  0 siblings, 0 replies; 6+ messages in thread
From: Wolfgang Bangerth @ 2003-01-15 21:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/9298; it has been noted by GNATS.

From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
Cc: gcc-bugs@gcc.gnu.org, <gcc-gnats@gcc.gnu.org>
Subject: Re: c++/9298: [3.4 regression] [new parser] ICE with function-pointer-type
 template args
Date: Wed, 15 Jan 2003 15:35:39 -0600 (CST)

 > sorry for the confusion, I was *quite* wrong.
 
 No problem :-) You're hereby sentenced to three days in the C++ testcase 
 diction jail:
   struct bars {
     bool behind ();
   };
   ...
   if (bars().behind())
     printf("foo :-)");
 
 
 > Let's have another look at the code:
 > 
 > The declaration of foo as a static template function is of course legal.
 > But I disagree with you when you say
 > 
 > > It's illegal, though, to use its address as a template parameter!
 > 
 > Why should it be illegal? You can use the address of a static variable as
 > a template parameter, too:
 > 
 > ------------snip here-------------
 > int i;
 > template <int*> void foo() {}
 > template void foo<&i> ();
 > ----------------------------------
 
 Values for pointer- or reference-type template arguments need to have 
 _external_ linkage. "int i" does have that, "static void foo()" doesn't.
 
 
 > Given that, the following code should compile IMHO (the EDG front-end
 > thinks so, too):
 > 
 > ----------------------snip here-------------------
 > struct A
 > {
 >     typedef void (*pfun)();
 > 
 >     template <pfun> static void bar() {}
 > };
 > 
 > template <int> static void foo() {}
 > 
 > template void A::bar< &foo<0> >();
 > ----------------------snip here-------------------
 > 
 > Alas, each gcc version since 2.95.x rejects the code with a message similar to
 > 
 > bug.cc:10: `&foo<0>' is not a valid template argument
 > bug.cc:10: template-id `bar<(&foo<0>)>' for `void A::bar()' does not match any 
 >    template declaration
 
 EDG is wrong (surprisingly), and gcc is right: foo has internal linkage, 
 and its address is therefore not a valid one for a template parameter.
 Once you remove the static from the declaration of foo, it compiles 
 cleanly.
 
 It's just too bad that here the error message is not really good:
 
 GCC2.96:
 tmp/g> gcc -c x.cc
 x.cc:10: `&foo<0>' is not a valid template argument
 x.cc:10: template-id `bar<(&foo<0>)>' for `A::bar ()' does not match
 any template declaration
 
 PRESENT CVS:
 tmp/g> ../build-gcc/gcc-install/bin/gcc -c x.cc
 x.cc:10: error: template-id `bar<(&foo<0>)>' for `void A::bar()' does not match
    any template declaration
 
 
 It's particularly bad since gcc-CVS knows about this. If I take your 
 example from above, and make it invalid by adding "static" to the 
 declaration of "int i", then I get:
 
 x.cc:3: error: address of non-extern `i' cannot be used as template argument
 x.cc:3: error: template-id `foo<(&i)>' for `void foo()' does not match any
    template declaration
 
 
 Regards
   Wolfgang
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth             email:            bangerth@ticam.utexas.edu
                               www: http://www.ticam.utexas.edu/~bangerth/
 
 
 


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

* Re: c++/9298: [3.4 regression] [new parser] ICE with function-pointer-type template args
@ 2003-01-15 17:16 Wolfgang Bangerth
  0 siblings, 0 replies; 6+ messages in thread
From: Wolfgang Bangerth @ 2003-01-15 17:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/9298; it has been noted by GNATS.

From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: Volker Reichelt <reichelt@igpm.rwth-aachen.de>, <gcc-bugs@gcc.gnu.org>,
   <gcc-gnats@gcc.gnu.org>
Cc:  
Subject: Re: c++/9298: [3.4 regression] [new parser] ICE with function-pointer-type
 template args
Date: Wed, 15 Jan 2003 11:11:32 -0600 (CST)

 >     BTW, the code is illegal (there are three bugs):
 
 Of course the code is illegal, but I can really only spot one error :-)
 
 >     template<int> static int foo();
 >                   ^^^^^^
 
 Why shouldn't a template not be a static function? It's illegal, though, 
 to use its address as a template parameter!
 
 
 >     template   int CPU::dispatch<&template foo<2> > ();
 >             ^^                    ^^^^^^^^
 
 The one at the left: That's an explicit instantiation, not specialization, 
 so this is legal syntax. The syntax at the right should be wrong, though 
 (well, not quite sure, should it?).
 
 W.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth             email:            bangerth@ticam.utexas.edu
                               www: http://www.ticam.utexas.edu/~bangerth/
 
 


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

* Re: c++/9298: [3.4 regression] [new parser] ICE with function-pointer-type template args
@ 2003-01-15  9:48 reichelt
  0 siblings, 0 replies; 6+ messages in thread
From: reichelt @ 2003-01-15  9:48 UTC (permalink / raw)
  To: bangerth, gcc-bugs, gcc-prs, nobody

Synopsis: [3.4 regression] [new parser] ICE with function-pointer-type template args

State-Changed-From-To: open->analyzed
State-Changed-By: reichelt
State-Changed-When: Wed Jan 15 01:48:42 2003
State-Changed-Why:
    Confirmed.
    
    BTW, the code is illegal (there are three bugs):
    
    template<int> static int foo();
                  ^^^^^^
    template   int CPU::dispatch<&template foo<2> > ();
            ^^                    ^^^^^^^^
    
    The correct verion would be
    
    template<int> int foo();
    template<> int CPU::dispatch<&foo<2> > ();

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9298


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

end of thread, other threads:[~2003-01-22 22:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-15 20:46 c++/9298: [3.4 regression] [new parser] ICE with function-pointer-type template args Volker Reichelt
  -- strict thread matches above, loose matches on Subject: below --
2003-01-22 22:25 mmitchel
2003-01-15 22:16 Volker Reichelt
2003-01-15 21:36 Wolfgang Bangerth
2003-01-15 17:16 Wolfgang Bangerth
2003-01-15  9:48 reichelt

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