public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14389] New: Can't define inline overloaded template function members out of their class.
@ 2004-03-02 19:14 gcc-bugzilla at gcc dot gnu dot org
  2004-03-02 19:49 ` [Bug c++/14389] " bangerth at dealii dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2004-03-02 19:14 UTC (permalink / raw)
  To: gcc-bugs



Environment:
System: Linux alpha.tchume.net 2.6.3 #1 SMP Fri Feb 27 15:52:02 UTC 2004 x86_64 GNU/Linux
Architecture: x86_64

	
host: i486-pc-linux-gnu
build: i486-pc-linux-gnu
target: i486-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux

How-To-Repeat:
Compile fine:

#include <iostream>

struct S {

 template< typename _B, typename _A >
 inline void
 foo() { std::cout << "AB\n"; }

 template< typename _A >
 inline void
 foo() { std::cout << "A\n"; }

};

int
main() {

  S s;
  s.foo< void >();
  s.foo< void, void >();
}


Don't compile:

struct S {

 template< typename _B, typename _A >
 inline void
 foo();

 template< typename _A >
 inline void
 foo();

};

template< typename _A >
inline void
S::foo() { std::cout << "A\n"; }

template< typename _B, typename _A >
inline void
S::foo() { std::cout << "AB\n"; }

int
main() {

  S s;
  s.foo< void >();
  s.foo< void, void >();
}


ICE(in tsubst, at cp/pt.c:6762): 

struct S {

 template< typename _A >
 inline void
 foo();

 template< int _i >
 inline void
 foo();
 
}; // struct S

template< typename _A >
inline void
S::foo() { std::cout << "A\n"; }

template< int _i >
inline void
foo() { std::cout << "const\n"; };


int
main() {

  S s;
  s.foo< 0 >();
  s.foo< void >();
}

-- 
           Summary: Can't define inline overloaded template function members
                    out of their class.
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fasbjx at free dot fr
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i486-pc-linux-gnu
  GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu


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


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

* [Bug c++/14389] Can't define inline overloaded template function members out of their class.
  2004-03-02 19:14 [Bug c++/14389] New: Can't define inline overloaded template function members out of their class gcc-bugzilla at gcc dot gnu dot org
@ 2004-03-02 19:49 ` bangerth at dealii dot org
  2004-03-02 19:52 ` [Bug c++/14389] Out-of-line of overloaded template rejected bangerth at dealii dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2004-03-02 19:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-03-02 19:49 -------
Confirmed: 
-------------------- 
struct S { 
    template< typename B, typename A > void foo(); 
    template< typename A >             void foo(); 
}; 
 
template< typename A >             void S::foo() {} 
template< typename B, typename A > void S::foo() {} 
 
template void S::foo<void> (); 
template void S::foo<void,void> (); 
------------------------- 
This fails with 3.3.4, 3.4 and mainline and all other versions I have here: 
 
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc 
x.cc:18: error: redefinition of `void S::foo()' 
x.cc:14: error: `void S::foo()' previously declared here 
x.cc:18: error: got 2 template parameters for `void S::foo()' 
x.cc:18: error:   but 1 required 
x.cc:14: internal compiler error: tree check: accessed elt 2 of tree_vec with 
1 elts in tsubst, at cp/pt.c:6729 
Please submit a full bug report, 
 
The last example also fails, but for the sake of having only one problem 
per report I'll submit it in another PR. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
      Known to fail|                            |2.95.3 3.2.3 3.3.3 3.4.0
                   |                            |3.5.0
   Last reconfirmed|0000-00-00 00:00:00         |2004-03-02 19:49:08
               date|                            |


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


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

* [Bug c++/14389] Out-of-line of overloaded template rejected
  2004-03-02 19:14 [Bug c++/14389] New: Can't define inline overloaded template function members out of their class gcc-bugzilla at gcc dot gnu dot org
  2004-03-02 19:49 ` [Bug c++/14389] " bangerth at dealii dot org
@ 2004-03-02 19:52 ` bangerth at dealii dot org
  2004-03-02 20:25 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2004-03-02 19:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-03-02 19:52 -------
The last example is now PR 14390. 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
            Summary|Can't define inline         |Out-of-line of overloaded
                   |overloaded template function|template rejected
                   |members out of their class. |


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


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

* [Bug c++/14389] Out-of-line of overloaded template rejected
  2004-03-02 19:14 [Bug c++/14389] New: Can't define inline overloaded template function members out of their class gcc-bugzilla at gcc dot gnu dot org
  2004-03-02 19:49 ` [Bug c++/14389] " bangerth at dealii dot org
  2004-03-02 19:52 ` [Bug c++/14389] Out-of-line of overloaded template rejected bangerth at dealii dot org
@ 2004-03-02 20:25 ` pinskia at gcc dot gnu dot org
  2004-03-03 13:44 ` giovannibajo at libero dot it
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-03-02 20:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-03-02 20:24 -------
And here is the backtrace for the tree-ssa:
#0  0x9002c878 in exit ()
#1  0x002b5560 in diagnostic_report_diagnostic (context=0x2b5560, diagnostic=0x27f464) at /
Users/pinskia/src/gcc-tree-ssa/gcc/gcc/diagnostic.c:360
#2  0x002b5560 in diagnostic_report_diagnostic (context=0x9d7ad0, diagnostic=0xbfffefc0) at /
Users/pinskia/src/gcc-tree-ssa/gcc/gcc/diagnostic.c:360
#3  0x002b5bf8 in internal_error (msgid=0x8be3f0 "tree check: accessed elt %d of tree_vec with %d 
elts in %s, at %s:%d") at /Users/pinskia/src/gcc-tree-ssa/gcc/gcc/diagnostic.c:538
#4  0x0028bb1c in tree_vec_elt_check_failed (idx=1, len=1, file=0x8a4ae0 "/Users/pinskia/src/gcc-
tree-ssa/gcc/gcc/cp/pt.c", line=6729, function=0x8a6254 "tsubst") at /Users/pinskia/src/gcc-tree-
ssa/gcc/gcc/tree.c:4929
#5  0x0009b290 in tsubst (t=0x41772934, args=0x41774060, complain=tf_error, 
in_decl=0x41770174) at /Users/pinskia/src/gcc-tree-ssa/gcc/gcc/cp/pt.c:6729
#6  0x000934dc in tsubst_template_arg (t=0x41772934, args=0x41774060, complain=tf_error, 
in_decl=0x41770174) at /Users/pinskia/src/gcc-tree-ssa/gcc/gcc/cp/pt.c:5684
#7  0x00093780 in tsubst_template_args (t=0x416bbdc0, args=0x41774060, complain=tf_error, 
in_decl=0x41770174) at /Users/pinskia/src/gcc-tree-ssa/gcc/gcc/cp/pt.c:5735
#8  0x00096cec in tsubst_decl (t=0x41770174, args=0x41774060, type=0x4176ed14, 
complain=tf_error) at /Users/pinskia/src/gcc-tree-ssa/gcc/gcc/cp/pt.c:6080
#9  0x0009a244 in tsubst (t=0x41770174, args=0x41774060, complain=tf_error, 
in_decl=0x4177026c) at /Users/pinskia/src/gcc-tree-ssa/gcc/gcc/cp/pt.c:6634
#10 0x000acb94 in instantiate_template (tmpl=0x4177026c, targ_ptr=0x41774060, 
complain=tf_error) at /Users/pinskia/src/gcc-tree-ssa/gcc/gcc/cp/pt.c:8697
#11 0x00076568 in check_explicit_specialization (declarator=0x416a84ec, decl=0x41772d90, 
template_count=0, flags=0) at /Users/pinskia/src/gcc-tree-ssa/gcc/gcc/cp/pt.c:1901
#12 0x00041fb0 in grokfndecl (ctype=0x4176e744, type=0x4176ed14, declarator=0x4176fd40, 
orig_declarator=0x416a84ec, virtualp=0, flags=NO_SPECIAL, quals=0x0, raises=0x0, check=1, 
friendp=0, publicp=1, inlinep=0, funcdef_flag=0, template_count=0, in_namespace=0x0) at /Users/
pinskia/src/gcc-tree-ssa/gcc/gcc/cp/decl.c:5684
#13 0x0004e8bc in grokdeclarator (declarator=0x416a84ec, declspecs=0x41769f78, 
decl_context=NORMAL, initialized=0, attrlist=0x0) at /Users/pinskia/src/gcc-tree-ssa/gcc/gcc/cp/
decl.c:8345
#14 0x00132f14 in cp_parser_explicit_instantiation (parser=0x4176e6c8) at /Users/pinskia/src/gcc-
tree-ssa/gcc/gcc/cp/parser.c:8681
#15 0x0012f4a8 in cp_parser_declaration (parser=0x4176e6c8) at /Users/pinskia/src/gcc-tree-ssa/
gcc/gcc/cp/parser.c:6444
#16 0x0012f318 in cp_parser_declaration_seq_opt (parser=0x4176e6c8) at /Users/pinskia/src/gcc-
tree-ssa/gcc/gcc/cp/parser.c:6382
#17 0x001290a4 in cp_parser_translation_unit (parser=0x4176e6c8) at /Users/pinskia/src/gcc-tree-
ssa/gcc/gcc/cp/parser.c:2383
#18 0x00140a70 in c_parse_file () at /Users/pinskia/src/gcc-tree-ssa/gcc/gcc/cp/parser.c:15370
#19 0x00252218 in c_common_parse_file (set_yydebug=0) at /Users/pinskia/src/gcc-tree-ssa/gcc/
gcc/c-opts.c:1234
#20 0x002ae750 in compile_file () at /Users/pinskia/src/gcc-tree-ssa/gcc/gcc/toplev.c:1869
#21 0x002b47e4 in do_compile () at /Users/pinskia/src/gcc-tree-ssa/gcc/gcc/toplev.c:4570
#22 0x002b48c8 in toplev_main (argc=2, argv=0xbffffca0) at /Users/pinskia/src/gcc-tree-ssa/gcc/
gcc/toplev.c:4610
#23 0x00269da0 in main (argc=2, argv=0xbffffca0) at /Users/pinskia/src/gcc-tree-ssa/gcc/gcc/
main.c:35

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal
           Keywords|                            |ice-on-valid-code


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


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

* [Bug c++/14389] Out-of-line of overloaded template rejected
  2004-03-02 19:14 [Bug c++/14389] New: Can't define inline overloaded template function members out of their class gcc-bugzilla at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2004-03-03 13:44 ` giovannibajo at libero dot it
@ 2004-03-03 13:44 ` giovannibajo at libero dot it
  2004-03-03 17:07 ` giovannibajo at libero dot it
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: giovannibajo at libero dot it @ 2004-03-03 13:44 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-03-03 13:44 -------
*** Bug 14390 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at dealii dot org


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


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

* [Bug c++/14389] Out-of-line of overloaded template rejected
  2004-03-02 19:14 [Bug c++/14389] New: Can't define inline overloaded template function members out of their class gcc-bugzilla at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2004-03-02 20:25 ` pinskia at gcc dot gnu dot org
@ 2004-03-03 13:44 ` giovannibajo at libero dot it
  2004-03-03 13:44 ` giovannibajo at libero dot it
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: giovannibajo at libero dot it @ 2004-03-03 13:44 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-03-03 13:44 -------
I have a patch for this.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |giovannibajo at libero dot
                   |dot org                     |it
             Status|NEW                         |ASSIGNED


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


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

* [Bug c++/14389] Out-of-line of overloaded template rejected
  2004-03-02 19:14 [Bug c++/14389] New: Can't define inline overloaded template function members out of their class gcc-bugzilla at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2004-03-03 13:44 ` giovannibajo at libero dot it
@ 2004-03-03 17:07 ` giovannibajo at libero dot it
  2004-03-03 18:26 ` giovannibajo at libero dot it
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: giovannibajo at libero dot it @ 2004-03-03 17:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-03-03 17:07 -------
*** Bug 14390 has been marked as a duplicate of this bug. ***

-- 


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


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

* [Bug c++/14389] Out-of-line of overloaded template rejected
  2004-03-02 19:14 [Bug c++/14389] New: Can't define inline overloaded template function members out of their class gcc-bugzilla at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2004-03-03 17:07 ` giovannibajo at libero dot it
@ 2004-03-03 18:26 ` giovannibajo at libero dot it
  2004-05-03 10:11 ` cvs-commit at gcc dot gnu dot org
  2004-05-03 10:16 ` giovannibajo at libero dot it
  8 siblings, 0 replies; 10+ messages in thread
From: giovannibajo at libero dot it @ 2004-03-03 18:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-03-03 18:26 -------
Patch here, waiting for review:
http://gcc.gnu.org/ml/gcc-patches/2004-03/msg00295.html


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


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


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

* [Bug c++/14389] Out-of-line of overloaded template rejected
  2004-03-02 19:14 [Bug c++/14389] New: Can't define inline overloaded template function members out of their class gcc-bugzilla at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2004-03-03 18:26 ` giovannibajo at libero dot it
@ 2004-05-03 10:11 ` cvs-commit at gcc dot gnu dot org
  2004-05-03 10:16 ` giovannibajo at libero dot it
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-05-03 10:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-05-03 10:11 -------
Subject: Bug 14389

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	giovannibajo@gcc.gnu.org	2004-05-03 10:11:22

Modified files:
	gcc/cp         : cp-tree.h decl2.c decl.c friend.c pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: member5.C 

Log message:
	PR c++/14389
	* decl2.c (check_classfn): For member templates, compare also the
	template parameters to match the declaration.
	* cp-tree.h: Adjust declaration of check_classfn.
	* decl.c (start_decl, grokfndecl): Adjust callers of check_classfn.
	* friend.c (do_friend): Likewise.
	* pt.c (tsubst_friend_function): Likewise.
	
	PR c++/14389
	* g++.dg/template/member5.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.965&r2=1.966
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.705&r2=1.706
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1204&r2=1.1205
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/friend.c.diff?cvsroot=gcc&r1=1.95&r2=1.96
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.849&r2=1.850
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3716&r2=1.3717
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/member5.C.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


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

* [Bug c++/14389] Out-of-line of overloaded template rejected
  2004-03-02 19:14 [Bug c++/14389] New: Can't define inline overloaded template function members out of their class gcc-bugzilla at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2004-05-03 10:11 ` cvs-commit at gcc dot gnu dot org
@ 2004-05-03 10:16 ` giovannibajo at libero dot it
  8 siblings, 0 replies; 10+ messages in thread
From: giovannibajo at libero dot it @ 2004-05-03 10:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-05-03 10:16 -------
Approval by Jason here:
http://gcc.gnu.org/ml/gcc-patches/2004-04/msg02020.html

This bug is now fixed for GCC 3.5.0. Thank you for your report!

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |3.5.0


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


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

end of thread, other threads:[~2004-05-03 10:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-02 19:14 [Bug c++/14389] New: Can't define inline overloaded template function members out of their class gcc-bugzilla at gcc dot gnu dot org
2004-03-02 19:49 ` [Bug c++/14389] " bangerth at dealii dot org
2004-03-02 19:52 ` [Bug c++/14389] Out-of-line of overloaded template rejected bangerth at dealii dot org
2004-03-02 20:25 ` pinskia at gcc dot gnu dot org
2004-03-03 13:44 ` giovannibajo at libero dot it
2004-03-03 13:44 ` giovannibajo at libero dot it
2004-03-03 17:07 ` giovannibajo at libero dot it
2004-03-03 18:26 ` giovannibajo at libero dot it
2004-05-03 10:11 ` cvs-commit at gcc dot gnu dot org
2004-05-03 10:16 ` giovannibajo at libero dot it

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