public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13744] New: ICE when using implicit copy constructor for struct defined in template function
@ 2004-01-19 17:39 thomharp at charter dot net
  2004-01-19 17:42 ` [Bug c++/13744] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: thomharp at charter dot net @ 2004-01-19 17:39 UTC (permalink / raw)
  To: gcc-bugs

The following code fails with an ICE (errors are transcribed below).  I haven't
found any structural changes I can make to this code without making the problem
go away, so I can't be sure what combination of constructs causes the problem,
but it's clear that this only happens when using the implicit copy constructor
for a type defined within a template function (or member function of a template
class) which derives from a base type with virtual functions supplied in the
newly defined type:

struct Base {                                                                       
        virtual Base *copy(void) = 0;                                               
        virtual ~Base() { }                                                         
};  
                                                                                
                                                                               
    template <typename T>
void make(void) {                                                                   
        struct Test : public Base {                                                 
                Base *copy(void) {                                                  
                        return new Test(*this);                                     
                }                                                                   
        };                                                                          
        new Test();                                                                 
}                                                                                   
                                                                                    
int main(void) {                                                                    
        make<double>();                                                             
        return 0;                                                                   
}

compiling this with 'c++ main.cpp' gives the following errors:

main.cpp: In member function `Base* make()::Test::copy() [with T = double]':
main.cpp:13:   instantiated from here
main.cpp:10: Internal compiler error in find_function_data, at function.c:310
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugs.gentoo.org/> for instructions.
thom@rudicles functor $ 

Also known to fail on gcc-3.2.3

-- 
           Summary: ICE when using implicit copy constructor for struct
                    defined in template function
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: thomharp at charter dot net
                CC: gcc-bugs at gcc dot gnu dot org,thomharp at charter dot
                    net
  GCC host triplet: gentoo linux, kernel 2.4.20, athlon k6


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


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

* [Bug c++/13744] ICE when using implicit copy constructor for struct defined in template function
  2004-01-19 17:39 [Bug c++/13744] New: ICE when using implicit copy constructor for struct defined in template function thomharp at charter dot net
@ 2004-01-19 17:42 ` pinskia at gcc dot gnu dot org
  2004-01-31  4:04 ` giovannibajo at libero dot it
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-19 17:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-19 17:42 -------
Confirmed but not a regression.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |ice-on-valid-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-01-19 17:42:14
               date|                            |


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


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

* [Bug c++/13744] ICE when using implicit copy constructor for struct defined in template function
  2004-01-19 17:39 [Bug c++/13744] New: ICE when using implicit copy constructor for struct defined in template function thomharp at charter dot net
  2004-01-19 17:42 ` [Bug c++/13744] " pinskia at gcc dot gnu dot org
@ 2004-01-31  4:04 ` giovannibajo at libero dot it
  2004-01-31  4:09 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: giovannibajo at libero dot it @ 2004-01-31  4:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-01-31 04:04 -------
Andrew, would you mind listening the versions that you tested in the known-to-
fail? Thanks.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |giovannibajo at libero dot
                   |                            |it
      Known to fail|                            |3.2.3 3.3.2


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


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

* [Bug c++/13744] ICE when using implicit copy constructor for struct defined in template function
  2004-01-19 17:39 [Bug c++/13744] New: ICE when using implicit copy constructor for struct defined in template function thomharp at charter dot net
  2004-01-19 17:42 ` [Bug c++/13744] " pinskia at gcc dot gnu dot org
  2004-01-31  4:04 ` giovannibajo at libero dot it
@ 2004-01-31  4:09 ` pinskia at gcc dot gnu dot org
  2004-06-25 23:44 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-31  4:09 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-31 04:09 -------
Also 2.91.66 and 2.96 20000731 (Red Hat Linux 7.2 2.96-109) fails the same way.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|3.2.3 3.3.2 3.0.4 2.95.3    |3.2.3 3.3.2 3.0.4 2.95.3
                   |                            |3.2.2


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


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

* [Bug c++/13744] ICE when using implicit copy constructor for struct defined in template function
  2004-01-19 17:39 [Bug c++/13744] New: ICE when using implicit copy constructor for struct defined in template function thomharp at charter dot net
                   ` (2 preceding siblings ...)
  2004-01-31  4:09 ` pinskia at gcc dot gnu dot org
@ 2004-06-25 23:44 ` pinskia at gcc dot gnu dot org
  2004-10-04 10:07 ` giovannibajo at libero dot it
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-25 23:44 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-25 23:35 -------
I get a different ICE on the mainline:
pr13744.cc:19: internal compiler error: tree check: expected constructor, have statement_list in 
mark_vtable_entries, at cp/decl2.c:1312
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

-- 


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


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

* [Bug c++/13744] ICE when using implicit copy constructor for struct defined in template function
  2004-01-19 17:39 [Bug c++/13744] New: ICE when using implicit copy constructor for struct defined in template function thomharp at charter dot net
                   ` (3 preceding siblings ...)
  2004-06-25 23:44 ` pinskia at gcc dot gnu dot org
@ 2004-10-04 10:07 ` giovannibajo at libero dot it
  2004-10-04 10:15 ` giovannibajo at libero dot it
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: giovannibajo at libero dot it @ 2004-10-04 10:07 UTC (permalink / raw)
  To: gcc-bugs


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

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


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


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

* [Bug c++/13744] ICE when using implicit copy constructor for struct defined in template function
  2004-01-19 17:39 [Bug c++/13744] New: ICE when using implicit copy constructor for struct defined in template function thomharp at charter dot net
                   ` (4 preceding siblings ...)
  2004-10-04 10:07 ` giovannibajo at libero dot it
@ 2004-10-04 10:15 ` giovannibajo at libero dot it
  2004-10-04 10:43 ` reichelt at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: giovannibajo at libero dot it @ 2004-10-04 10:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-10-04 10:14 -------
Slightly reduced testcase:
--------------------------------------
struct B {
  virtual B *copy(void) = 0;
};


template <typename T>
void foo(void) {

  struct D : public B {
    B *copy(void) {
      return new D(*this);
    }
  };

  new D();
}

template void foo<void>(void);
--------------------------------------
ice.cc:17:   instantiated from here
ice.cc:11: internal compiler error: in find_function_data, at function.c:233

Now we get this message on mainline too.


(gdb) list
228
229       for (p = outer_function_chain; p; p = p->outer)
230         if (p->decl == decl)
231           return p;
232
233       gcc_unreachable ();
234     }
235
236     /* Save the current context for compilation of a nested function.
237        This is called from language-specific code.  The caller should use


(gdb) p decl
$2 = 0x402b6740
(gdb) pt
 <function_decl 0x402b6740 foo
    type <function_type 0x40231c3c
        type <void_type 0x4022fa6c void type_6 VOID
            align 8 symtab 0 alias set -1
            pointer_to_this <pointer_type 0x4022fae0>>
        type_6 QI
        size <integer_cst 0x4021e1c8 constant invariant 8>
        unit size <integer_cst 0x4021e1e0 constant invariant 1>
        align 8 symtab 0 alias set -1
        arg-types <tree_list 0x40232120 value <void_type 0x4022fa6c void>>>
    public static weak no-static-chain decl_1 decl_5 QI file ice.cc line 7
    result <result_decl 0x402b6c3c type <void_type 0x4022fa6c void>
        ignored VOID file ice.cc line 7
        align 8 context <function_decl 0x402b6740 foo>> initial <block 
0x402bd0d0>
    pending-inline-info 0x402be244 template-info 0x402b45a0
    saved-insns 0x4021ac00>

(gdb) bt
#0  fancy_abort (file=0x84c84b2 "../../gcc/gcc/function.c", line=233,
    function=0x84c849f "find_function_data") at ../../gcc/gcc/diagnostic.c:591
#1  0x0828c245 in find_function_data (decl=0x402b6740)
    at ../../gcc/gcc/function.c:233
#2  0x0828c266 in push_function_context_to (context=0x0)
    at ../../gcc/gcc/function.c:253
#3  0x080f03e5 in synthesize_method (fndecl=0x402b8658)
    at ../../gcc/gcc/cp/method.c:718
#4  0x080565e3 in build_over_call (cand=0x85e229c, flags=3)
    at ../../gcc/gcc/cp/call.c:4765
#5  0x080578e8 in build_new_method_call (instance=0x402bf440, fns=0x85e229c,
    args=0x402b9b88, conversion_path=0x40217980, flags=3)
    at ../../gcc/gcc/cp/call.c:5341
#6  0x080eb90e in build_new_1 (exp=0x4028f32c) at ../../gcc/gcc/cp/init.c:2061
#7  0x080eae74 in build_new (placement=0x0, type=0x402b6d98, nelts=0x14,
    init=0x402b6d98, use_global_new=0) at ../../gcc/gcc/cp/init.c:1675
#8  0x0808e804 in tsubst_copy_and_build (t=0x402b1af8, args=0x402b4900,
    complain=3, in_decl=0x402b61d0, function_p=0 '\0')
    at ../../gcc/gcc/cp/pt.c:8357
#9  0x0808d098 in tsubst_expr (t=0x402b1af8, args=0x402b4900, complain=3,
    in_decl=0x402b61d0) at ../../gcc/gcc/cp/pt.c:8082
#10 0x0808c387 in tsubst_expr (t=0x402b51e0, args=0x402b4900, complain=3,
    in_decl=0x402b61d0) at ../../gcc/gcc/cp/pt.c:7830
#11 0x0808be95 in tsubst_expr (t=0x402b0140, args=0x402b4900, complain=3,
    in_decl=0x402b61d0) at ../../gcc/gcc/cp/pt.c:7965
#12 0x0808be95 in tsubst_expr (t=0x402b0118, args=0x402b4900, complain=3,
    in_decl=0x402b61d0) at ../../gcc/gcc/cp/pt.c:7965
#13 0x08094cdd in instantiate_decl (d=0x402b70e8, defer_ok=0, undefined_ok=0)
    at ../../gcc/gcc/cp/pt.c:11200
#14 0x0809544b in instantiate_pending_templates (retries=1)
    at ../../gcc/gcc/cp/pt.c:11297
#15 0x080b6396 in cp_finish_file () at ../../gcc/gcc/cp/decl2.c:2788
#16 0x0813f396 in c_common_parse_file (set_yydebug=0)
    at ../../gcc/gcc/c-opts.c:1098
#17 0x083b6206 in compile_file () at ../../gcc/gcc/toplev.c:985
#18 0x083b78e5 in do_compile () at ../../gcc/gcc/toplev.c:2069
#19 0x083b7949 in toplev_main (argc=2, argv=0xbfffeb14)
    at ../../gcc/gcc/toplev.c:2101
#20 0x08148ba3 in main (argc=2, argv=0xbfffeb14) at ../../gcc/gcc/main.c:35


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2004-09-25 16:45:26         |2004-10-04 10:15:02
               date|                            |


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


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

* [Bug c++/13744] ICE when using implicit copy constructor for struct defined in template function
  2004-01-19 17:39 [Bug c++/13744] New: ICE when using implicit copy constructor for struct defined in template function thomharp at charter dot net
                   ` (5 preceding siblings ...)
  2004-10-04 10:15 ` giovannibajo at libero dot it
@ 2004-10-04 10:43 ` reichelt at gcc dot gnu dot org
  2005-03-11 20:42 ` giovannibajo at libero dot it
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-10-04 10:43 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From reichelt at gcc dot gnu dot org  2004-10-04 10:43 -------
Here's something without inheritance:

=============================================
template<int> void foo()
{
    struct A
    {
        virtual void bar() { A a(*this); }
    } a;
}

void baz()
{
    foo<0>();
}
=============================================


-- 


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


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

* [Bug c++/13744] ICE when using implicit copy constructor for struct defined in template function
  2004-01-19 17:39 [Bug c++/13744] New: ICE when using implicit copy constructor for struct defined in template function thomharp at charter dot net
                   ` (6 preceding siblings ...)
  2004-10-04 10:43 ` reichelt at gcc dot gnu dot org
@ 2005-03-11 20:42 ` giovannibajo at libero dot it
  2005-04-12 10:57 ` reichelt at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: giovannibajo at libero dot it @ 2005-03-11 20:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2005-03-11 20:42 -------
*** Bug 20428 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |j-wang3 at northwestern dot
                   |                            |edu


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


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

* [Bug c++/13744] ICE when using implicit copy constructor for struct defined in template function
  2004-01-19 17:39 [Bug c++/13744] New: ICE when using implicit copy constructor for struct defined in template function thomharp at charter dot net
                   ` (7 preceding siblings ...)
  2005-03-11 20:42 ` giovannibajo at libero dot it
@ 2005-04-12 10:57 ` reichelt at gcc dot gnu dot org
  2005-04-12 18:08 ` mark at codesourcery dot com
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2005-04-12 10:57 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From reichelt at gcc dot gnu dot org  2005-04-12 10:57 -------
This was fixed on mainline by Kazu's cleanup:
http://gcc.gnu.org/ml/gcc-cvs/2005-04/msg00458.html

Mark, although this is not a regression, do you think this would
be appropriate for gcc 4.0.1? It's an ICE on valid code and the patch
is fairly trivial. It just removes an unnecessary computation (where
we used to ICE in this particular case).

Apart from that, do you want me to add a testcase to the testsuite?


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


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


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

* [Bug c++/13744] ICE when using implicit copy constructor for struct defined in template function
  2004-01-19 17:39 [Bug c++/13744] New: ICE when using implicit copy constructor for struct defined in template function thomharp at charter dot net
                   ` (8 preceding siblings ...)
  2005-04-12 10:57 ` reichelt at gcc dot gnu dot org
@ 2005-04-12 18:08 ` mark at codesourcery dot com
  2005-04-13 12:01 ` cvs-commit at gcc dot gnu dot org
  2005-04-13 12:07 ` reichelt at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: mark at codesourcery dot com @ 2005-04-12 18:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mark at codesourcery dot com  2005-04-12 18:08 -------
Subject: Re:  ICE when using implicit copy constructor for
 struct defined in template function

reichelt at gcc dot gnu dot org wrote:
> ------- Additional Comments From reichelt at gcc dot gnu dot org  2005-04-12 10:57 -------
> This was fixed on mainline by Kazu's cleanup:
> http://gcc.gnu.org/ml/gcc-cvs/2005-04/msg00458.html
> 
> Mark, although this is not a regression, do you think this would
> be appropriate for gcc 4.0.1? It's an ICE on valid code and the patch
> is fairly trivial. It just removes an unnecessary computation (where
> we used to ICE in this particular case).

I think this is above my risk threshold.  Thanks for asking though.

> Apart from that, do you want me to add a testcase to the testsuite?

That would be great, thanks!



-- 


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


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

* [Bug c++/13744] ICE when using implicit copy constructor for struct defined in template function
  2004-01-19 17:39 [Bug c++/13744] New: ICE when using implicit copy constructor for struct defined in template function thomharp at charter dot net
                   ` (9 preceding siblings ...)
  2005-04-12 18:08 ` mark at codesourcery dot com
@ 2005-04-13 12:01 ` cvs-commit at gcc dot gnu dot org
  2005-04-13 12:07 ` reichelt at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-04-13 12:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-04-13 12:01 -------
Subject: Bug 13744

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	reichelt@gcc.gnu.org	2005-04-13 12:01:03

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/inherit: local3.C 

Log message:
	PR c++/13744
	* g++.dg/inherit/local3.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5336&r2=1.5337
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/inherit/local3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


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

* [Bug c++/13744] ICE when using implicit copy constructor for struct defined in template function
  2004-01-19 17:39 [Bug c++/13744] New: ICE when using implicit copy constructor for struct defined in template function thomharp at charter dot net
                   ` (10 preceding siblings ...)
  2005-04-13 12:01 ` cvs-commit at gcc dot gnu dot org
@ 2005-04-13 12:07 ` reichelt at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2005-04-13 12:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From reichelt at gcc dot gnu dot org  2005-04-13 12:07 -------
Fixed on mainline (which will become 4.1.0).


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


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


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

end of thread, other threads:[~2005-04-13 12:07 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-19 17:39 [Bug c++/13744] New: ICE when using implicit copy constructor for struct defined in template function thomharp at charter dot net
2004-01-19 17:42 ` [Bug c++/13744] " pinskia at gcc dot gnu dot org
2004-01-31  4:04 ` giovannibajo at libero dot it
2004-01-31  4:09 ` pinskia at gcc dot gnu dot org
2004-06-25 23:44 ` pinskia at gcc dot gnu dot org
2004-10-04 10:07 ` giovannibajo at libero dot it
2004-10-04 10:15 ` giovannibajo at libero dot it
2004-10-04 10:43 ` reichelt at gcc dot gnu dot org
2005-03-11 20:42 ` giovannibajo at libero dot it
2005-04-12 10:57 ` reichelt at gcc dot gnu dot org
2005-04-12 18:08 ` mark at codesourcery dot com
2005-04-13 12:01 ` cvs-commit at gcc dot gnu dot org
2005-04-13 12:07 ` reichelt 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).