public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/25836]  New: G++ does not allow a conversion of templated types
@ 2006-01-18  2:57 jjamison at cs dot berkeley dot edu
  2006-01-18  3:03 ` [Bug c++/25836] " jjamison at cs dot berkeley dot edu
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: jjamison at cs dot berkeley dot edu @ 2006-01-18  2:57 UTC (permalink / raw)
  To: gcc-bugs

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

[jjamison@manzanita ~/harmonia/src-main/langs2/java/delta]$
/usr/misc/pkg/gcc-4.0.2/bin/g++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.0.2/configure --prefix=/usr/misc/pkg/gcc-4.0.2
--enable-shared --enable-threads=posix --with-system-zlib --with-gnu-as
--with-as=/usr/misc/pkg/binutils-2.16/bin/as --with-gnu-ld
--with-ld=/usr/misc/pkg/binutils-2.16/bin/ld --enable-__cxa_atexit
--enable-languages=c,c++
Thread model: posix
gcc version 4.0.2


Given the following code:
-----------Start Here-----------
template <class T>
class Iter {};

template <class T>
class SubIter : public Iter<T> {
   void insert(T);
};

class GraphBase {
public:
   class Node;
};

template<class T>
class Graph : public GraphBase {
   class Inner {
      Iter<typename Graph<T>::Node*> *get();
   };
};

template<class T>
Iter<typename Graph<T>::Node*> *Graph<T>::Inner::get() {
   SubIter<typename Graph<T>::Node*> *iter;
   iter->insert(0);
}

int main() {
   Iter<Graph<int>::Node*> *n2_iter = new SubIter<Graph<int>::Node*>();
}
------------End Here------------

Compile as follows:
-----------Start Here-----------
[jjamison@manzanita ~]$ /usr/misc/pkg/gcc-4.0.2/bin/g++ -Wall /tmp/bug.cc
/tmp/bug.cc: In function ‘int main()’:
/tmp/bug.cc:34: error: cannot convert ‘SubIter<GraphBase::Node*>*’ to
‘Iter<GraphBase::Node*>*’ in initialization
/tmp/bug.cc:34: warning: unused variable ‘n2_iter’
------------End Here------------

However, this conversion should be allowed.  Using other types
as the template parameter in the offending line shows the assignment
is allowable in ordinary circumstances.

Notes:
- Replacing `typename Graph<JavaType>::Node*'
    with `GraphBase::Node*' everywhere prevents the error.
- Making `get' a member of `Graph' instead of `Inner' prevents the error.
- Changing `get' to have a void return value prevents the error.
- Commenting out the `iter->insert(0);' line prevents the error.


-- 
           Summary: G++ does not allow a conversion of templated types
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jjamison at cs dot berkeley dot edu
 GCC build triplet: i386-redhat-linux
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux


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


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

* [Bug c++/25836] G++ does not allow a conversion of templated types
  2006-01-18  2:57 [Bug c++/25836] New: G++ does not allow a conversion of templated types jjamison at cs dot berkeley dot edu
@ 2006-01-18  3:03 ` jjamison at cs dot berkeley dot edu
  2006-01-18  3:17 ` [Bug c++/25836] [3.4/4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jjamison at cs dot berkeley dot edu @ 2006-01-18  3:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jjamison at cs dot berkeley dot edu  2006-01-18 03:03 -------
Also, the behavior is the same for gcc versions 4.0.1, 4.0.0, 3.4.4, and 3.4.3.
gcc version 3.3.4 does not appear to have the bug.


-- 


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


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

* [Bug c++/25836] [3.4/4.0/4.1/4.2 Regression] G++ does not allow a conversion of templated types
  2006-01-18  2:57 [Bug c++/25836] New: G++ does not allow a conversion of templated types jjamison at cs dot berkeley dot edu
  2006-01-18  3:03 ` [Bug c++/25836] " jjamison at cs dot berkeley dot edu
@ 2006-01-18  3:17 ` pinskia at gcc dot gnu dot org
  2006-01-18  3:19 ` pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-18  3:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-01-18 03:17 -------
Confirmed, this is a weird failure.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |rejects-valid
      Known to fail|                            |3.4.0 4.0.0 4.1.0 4.2.0
      Known to work|                            |3.3.3
   Last reconfirmed|0000-00-00 00:00:00         |2006-01-18 03:17:34
               date|                            |
            Summary|G++ does not allow a        |[3.4/4.0/4.1/4.2 Regression]
                   |conversion of templated     |G++ does not allow a
                   |types                       |conversion of templated
                   |                            |types
   Target Milestone|---                         |4.0.3


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


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

* [Bug c++/25836] [3.4/4.0/4.1/4.2 Regression] G++ does not allow a conversion of templated types
  2006-01-18  2:57 [Bug c++/25836] New: G++ does not allow a conversion of templated types jjamison at cs dot berkeley dot edu
  2006-01-18  3:03 ` [Bug c++/25836] " jjamison at cs dot berkeley dot edu
  2006-01-18  3:17 ` [Bug c++/25836] [3.4/4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
@ 2006-01-18  3:19 ` pinskia at gcc dot gnu dot org
  2006-01-18 21:24 ` janis at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-18  3:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-01-18 03:19 -------
Could you do a regression hunt on this bug?


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |janis at gcc dot gnu dot org


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


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

* [Bug c++/25836] [3.4/4.0/4.1/4.2 Regression] G++ does not allow a conversion of templated types
  2006-01-18  2:57 [Bug c++/25836] New: G++ does not allow a conversion of templated types jjamison at cs dot berkeley dot edu
                   ` (2 preceding siblings ...)
  2006-01-18  3:19 ` pinskia at gcc dot gnu dot org
@ 2006-01-18 21:24 ` janis at gcc dot gnu dot org
  2006-01-19  4:07 ` mmitchel at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janis at gcc dot gnu dot org @ 2006-01-18 21:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from janis at gcc dot gnu dot org  2006-01-18 21:24 -------
A regression hunt on powerpc-linux using the submitter's testcase identified
the following very large patch:

http://gcc.gnu.org/viewcvs?view=rev&rev=69130

r69130 | mmitchel | 2003-07-09 08:48:08 +0000 (Wed, 09 Jul 2003)


-- 

janis at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mmitchel at gcc dot gnu dot
                   |                            |org


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


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

* [Bug c++/25836] [3.4/4.0/4.1/4.2 Regression] G++ does not allow a conversion of templated types
  2006-01-18  2:57 [Bug c++/25836] New: G++ does not allow a conversion of templated types jjamison at cs dot berkeley dot edu
                   ` (3 preceding siblings ...)
  2006-01-18 21:24 ` janis at gcc dot gnu dot org
@ 2006-01-19  4:07 ` mmitchel at gcc dot gnu dot org
  2006-01-19  6:53 ` mmitchel at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-01-19  4:07 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |mark at codesourcery dot com
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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


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

* [Bug c++/25836] [3.4/4.0/4.1/4.2 Regression] G++ does not allow a conversion of templated types
  2006-01-18  2:57 [Bug c++/25836] New: G++ does not allow a conversion of templated types jjamison at cs dot berkeley dot edu
                   ` (5 preceding siblings ...)
  2006-01-19  6:53 ` mmitchel at gcc dot gnu dot org
@ 2006-01-19  6:53 ` mmitchel at gcc dot gnu dot org
  2006-01-19  6:56 ` mmitchel at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-01-19  6:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from mmitchel at gcc dot gnu dot org  2006-01-19 06:53 -------
Subject: Bug 25836

Author: mmitchel
Date: Thu Jan 19 06:53:34 2006
New Revision: 109944

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109944
Log:
        PR c++/25836
        * cp-tree.h (push_class_stack): New function.
        (pop_class_stack): Likewise.
        * class.c (class_stack_node): Add hidden field.
        (pushclass): Clear it.
        (push_class_stack): New function.
        (pop_class_stack): Likewise.
        (currently_open_class): Ignore hidden classes.
        (currently_open_derived_class): Likewise.
        * name-lookup.c (push_to_top_level): Call push_class_stack.
        (pop_from_top_level): Call pop_class_stack.
        PR c++/25836
        * g++.dg/template/init6.C: New test.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/template/init6.C
Modified:
    branches/gcc-4_0-branch/gcc/cp/ChangeLog
    branches/gcc-4_0-branch/gcc/cp/class.c
    branches/gcc-4_0-branch/gcc/cp/cp-tree.h
    branches/gcc-4_0-branch/gcc/cp/name-lookup.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/25836] [3.4/4.0/4.1/4.2 Regression] G++ does not allow a conversion of templated types
  2006-01-18  2:57 [Bug c++/25836] New: G++ does not allow a conversion of templated types jjamison at cs dot berkeley dot edu
                   ` (4 preceding siblings ...)
  2006-01-19  4:07 ` mmitchel at gcc dot gnu dot org
@ 2006-01-19  6:53 ` mmitchel at gcc dot gnu dot org
  2006-01-19  6:53 ` mmitchel at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-01-19  6:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from mmitchel at gcc dot gnu dot org  2006-01-19 06:53 -------
Subject: Bug 25836

Author: mmitchel
Date: Thu Jan 19 06:52:56 2006
New Revision: 109943

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109943
Log:
        PR c++/25836
        * cp-tree.h (push_class_stack): New function.
        (pop_class_stack): Likewise.
        * class.c (class_stack_node): Add hidden field.
        (pushclass): Clear it.
        (push_class_stack): New function.
        (pop_class_stack): Likewise.
        (currently_open_class): Ignore hidden classes.
        (currently_open_derived_class): Likewise.
        * name-lookup.c (push_to_top_level): Call push_class_stack.
        (pop_from_top_level): Call pop_class_stack.
        PR c++/25836
        * g++.dg/template/init6.C: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/init6.C
Modified:
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/class.c
    branches/gcc-4_1-branch/gcc/cp/cp-tree.h
    branches/gcc-4_1-branch/gcc/cp/name-lookup.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/25836] [3.4/4.0/4.1/4.2 Regression] G++ does not allow a conversion of templated types
  2006-01-18  2:57 [Bug c++/25836] New: G++ does not allow a conversion of templated types jjamison at cs dot berkeley dot edu
                   ` (6 preceding siblings ...)
  2006-01-19  6:53 ` mmitchel at gcc dot gnu dot org
@ 2006-01-19  6:56 ` mmitchel at gcc dot gnu dot org
  2006-01-19  6:59 ` [Bug c++/25836] [3.4 " mmitchel at gcc dot gnu dot org
  2006-01-19  7:48 ` gdr at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-01-19  6:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from mmitchel at gcc dot gnu dot org  2006-01-19 06:55 -------
Subject: Bug 25836

Author: mmitchel
Date: Thu Jan 19 06:55:53 2006
New Revision: 109945

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109945
Log:
        PR c++/25836
        * cp-tree.h (push_class_stack): New function.
        (pop_class_stack): Likewise.
        * class.c (class_stack_node): Add hidden field.
        (pushclass): Clear it.
        (push_class_stack): New function.
        (pop_class_stack): Likewise.
        (currently_open_class): Ignore hidden classes.
        (currently_open_derived_class): Likewise.
        * name-lookup.c (push_to_top_level): Call push_class_stack.
        (pop_from_top_level): Call pop_class_stack.
        PR c++/25836
        * g++.dg/template/init6.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/template/init6.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/name-lookup.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/25836] [3.4 Regression] G++ does not allow a conversion of templated types
  2006-01-18  2:57 [Bug c++/25836] New: G++ does not allow a conversion of templated types jjamison at cs dot berkeley dot edu
                   ` (7 preceding siblings ...)
  2006-01-19  6:56 ` mmitchel at gcc dot gnu dot org
@ 2006-01-19  6:59 ` mmitchel at gcc dot gnu dot org
  2006-01-19  7:48 ` gdr at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-01-19  6:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from mmitchel at gcc dot gnu dot org  2006-01-19 06:59 -------
Fixed in 4.0.3.


-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[3.4/4.0/4.1/4.2 Regression]|[3.4 Regression] G++ does
                   |G++ does not allow a        |not allow a conversion of
                   |conversion of templated     |templated types
                   |types                       |


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


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

* [Bug c++/25836] [3.4 Regression] G++ does not allow a conversion of templated types
  2006-01-18  2:57 [Bug c++/25836] New: G++ does not allow a conversion of templated types jjamison at cs dot berkeley dot edu
                   ` (8 preceding siblings ...)
  2006-01-19  6:59 ` [Bug c++/25836] [3.4 " mmitchel at gcc dot gnu dot org
@ 2006-01-19  7:48 ` gdr at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: gdr at gcc dot gnu dot org @ 2006-01-19  7:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from gdr at gcc dot gnu dot org  2006-01-19 07:48 -------
Fixed in 4.0.3 and higher.  Won't fix in 3.4.x


-- 

gdr at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2006-01-19  7:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-18  2:57 [Bug c++/25836] New: G++ does not allow a conversion of templated types jjamison at cs dot berkeley dot edu
2006-01-18  3:03 ` [Bug c++/25836] " jjamison at cs dot berkeley dot edu
2006-01-18  3:17 ` [Bug c++/25836] [3.4/4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
2006-01-18  3:19 ` pinskia at gcc dot gnu dot org
2006-01-18 21:24 ` janis at gcc dot gnu dot org
2006-01-19  4:07 ` mmitchel at gcc dot gnu dot org
2006-01-19  6:53 ` mmitchel at gcc dot gnu dot org
2006-01-19  6:53 ` mmitchel at gcc dot gnu dot org
2006-01-19  6:56 ` mmitchel at gcc dot gnu dot org
2006-01-19  6:59 ` [Bug c++/25836] [3.4 " mmitchel at gcc dot gnu dot org
2006-01-19  7:48 ` gdr 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).