public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11418] New: Nested template as arg to base class template confuses args
@ 2003-07-03  2:15 GccBugs at Skyler dot com
  2003-07-03  2:17 ` [Bug c++/11418] " GccBugs at Skyler dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: GccBugs at Skyler dot com @ 2003-07-03  2:15 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Nested template as arg to base class template confuses
                    args
           Product: gcc
           Version: 3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: GccBugs at Skyler dot com
                CC: gcc-bugs at gcc dot gnu dot org

In certain cases a class template used as a base class receives an incorrect 
type as a template argument.  If the derived class takes two type arguments 
which are used as arguments to two class templates, one nested inside the 
other, the problem occurs if the first argument is used with the inner template 
and the second argument is used with the outer template, and the resulting 
(inner) type is passed to the base class.  The type actually used by the base 
class uses the first argument of the derived class for BOTH the outer and inner 
templates.


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

* [Bug c++/11418] Nested template as arg to base class template confuses args
  2003-07-03  2:15 [Bug c++/11418] New: Nested template as arg to base class template confuses args GccBugs at Skyler dot com
@ 2003-07-03  2:17 ` GccBugs at Skyler dot com
  2003-07-03 12:50 ` pinskia at physics dot uc dot edu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: GccBugs at Skyler dot com @ 2003-07-03  2:17 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From GccBugs at Skyler dot com  2003-07-03 02:17 -------
Created an attachment (id=4334)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=4334&action=view)
Example and workaround of problem deriving with nested templates

Results using Cygwin under Windows 2000.


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

* [Bug c++/11418] Nested template as arg to base class template confuses args
  2003-07-03  2:15 [Bug c++/11418] New: Nested template as arg to base class template confuses args GccBugs at Skyler dot com
  2003-07-03  2:17 ` [Bug c++/11418] " GccBugs at Skyler dot com
@ 2003-07-03 12:50 ` pinskia at physics dot uc dot edu
  2003-07-03 16:45 ` [Bug c++/11418] implicit typename extension leads to wrong code bangerth at dealii dot org
  2003-07-04  5:40 ` Don at Skyler dot com
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-03 12:50 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From pinskia at physics dot uc dot edu  2003-07-03 12:50 -------
*** Bug 11416 has been marked as a duplicate of this bug. ***


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

* [Bug c++/11418] implicit typename extension leads to wrong code
  2003-07-03  2:15 [Bug c++/11418] New: Nested template as arg to base class template confuses args GccBugs at Skyler dot com
  2003-07-03  2:17 ` [Bug c++/11418] " GccBugs at Skyler dot com
  2003-07-03 12:50 ` pinskia at physics dot uc dot edu
@ 2003-07-03 16:45 ` bangerth at dealii dot org
  2003-07-04  5:40 ` Don at Skyler dot com
  3 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2003-07-03 16:45 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
            Summary|Nested template as arg to   |implicit typename extension
                   |base class template confuses|leads to wrong code
                   |args                        |


------- Additional Comments From bangerth at dealii dot org  2003-07-03 16:45 -------
Very interesting failure. In fact, I can confirm this with 3.2.x and 3.3,
but it is fixed in mainline (see below).

In essence: the code is wrong -- but previous versions of gcc accept
it via the implicit typename extension. Here's the line:
    struct Derived : public Base<Outer<U>::Inner<T> > { };
3.2 and 3.3 accept this line, but 3.4 rejects it, as it should
read correctly as
    struct Derived : public Base<typename Outer<U>::template Inner<T> > { };

Now, the amazing thing is that 3.2 and 3.3 generate the _wrong_ output for
the first line, and the correct one for the second. Since 3.4 only accepts
the last one, it always generates the correct output. Very interesting,
indeed.

So the proper workaround is to correct your code and don't rely on broken
gcc extensions :-(

Wolfgang


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

* [Bug c++/11418] implicit typename extension leads to wrong code
  2003-07-03  2:15 [Bug c++/11418] New: Nested template as arg to base class template confuses args GccBugs at Skyler dot com
                   ` (2 preceding siblings ...)
  2003-07-03 16:45 ` [Bug c++/11418] implicit typename extension leads to wrong code bangerth at dealii dot org
@ 2003-07-04  5:40 ` Don at Skyler dot com
  3 siblings, 0 replies; 5+ messages in thread
From: Don at Skyler dot com @ 2003-07-04  5:40 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From Don at Skyler dot com  2003-07-04 05:40 -------
Subject: Re:  implicit typename extension leads to wrong code

I didn't notice the missing "typename".  I don't think gcc produced
the usual "implicit typenames deprecated" warning.

On 3 Jul 2003 16:45:49 -0000, you wrote:

>PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
>
>http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11418
>
>
>bangerth at dealii dot org changed:
>
>           What    |Removed                     |Added
>----------------------------------------------------------------------------
>             Status|UNCONFIRMED                 |RESOLVED
>         Resolution|                            |FIXED
>            Summary|Nested template as arg to   |implicit typename extension
>                   |base class template confuses|leads to wrong code
>                   |args                        |
>
>
>------- Additional Comments From bangerth at dealii dot org  2003-07-03 16:45 -------
>Very interesting failure. In fact, I can confirm this with 3.2.x and 3.3,
>but it is fixed in mainline (see below).
>
>In essence: the code is wrong -- but previous versions of gcc accept
>it via the implicit typename extension. Here's the line:
>    struct Derived : public Base<Outer<U>::Inner<T> > { };
>3.2 and 3.3 accept this line, but 3.4 rejects it, as it should
>read correctly as
>    struct Derived : public Base<typename Outer<U>::template Inner<T> > { };
>
>Now, the amazing thing is that 3.2 and 3.3 generate the _wrong_ output for
>the first line, and the correct one for the second. Since 3.4 only accepts
>the last one, it always generates the correct output. Very interesting,
>indeed.
>
>So the proper workaround is to correct your code and don't rely on broken
>gcc extensions :-(
>
>Wolfgang
>
>
>
>------- You are receiving this mail because: -------
>You reported the bug, or are watching the reporter.


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

end of thread, other threads:[~2003-07-04  5:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-03  2:15 [Bug c++/11418] New: Nested template as arg to base class template confuses args GccBugs at Skyler dot com
2003-07-03  2:17 ` [Bug c++/11418] " GccBugs at Skyler dot com
2003-07-03 12:50 ` pinskia at physics dot uc dot edu
2003-07-03 16:45 ` [Bug c++/11418] implicit typename extension leads to wrong code bangerth at dealii dot org
2003-07-04  5:40 ` Don at Skyler dot com

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