Bug 35734 - [4.3/4.4 regression] ICE with copy constructor in derived class
Summary: [4.3/4.4 regression] ICE with copy constructor in derived class
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.3.1
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code, monitored
Depends on:
Blocks:
 
Reported: 2008-03-28 17:32 UTC by Volker Reichelt
Modified: 2008-04-09 14:25 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-03-28 18:33:16


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2008-03-28 17:32:41 UTC
The following valid code snippet triggers an ICE since GCC 4.3.0
when compiled with "-W":

=========================================
struct A
{
  A();
  template<typename T> A(const T&);
};

struct B : A
{
  B(const B&) {}
};
=========================================

bug.cc: In copy constructor 'B::B(const B&)':
bug.cc:9: internal compiler error: tree check: expected function_decl, have template_decl in type_has_user_nondefault_constructor, at cp/class.c:4063
Please submit a full bug report, [etc.]

In earlier versions we issued the warning:
bug.cc: In copy constructor 'B::B(const B&)':
bug.cc:9: warning: base class 'struct A' should be explicitly initialized in the copy constructor
Comment 1 Volker Reichelt 2008-03-28 17:37:06 UTC
Manuel, Jason, was probably introduced by your patch:

2008-02-14  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
	    Jason Merrill  <jason@redhat.com>

	PR c++/5645
	PR c++/11159
	* class.c (type_has_user_nondefault_constructor): New fn.
	* cp-tree.h: Declare it.
	* init.c (emit_mem_initializers): Use it for -W warning about
	missing base initializer.
Comment 2 Jason Merrill 2008-04-07 20:51:06 UTC
Subject: Bug 35734

Author: jason
Date: Mon Apr  7 20:50:21 2008
New Revision: 133987

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133987
Log:
        PR c++/35734
        * class.c (type_has_user_nondefault_constructor): A template
        counts as a nondefault constructor.

Added:
    trunk/gcc/testsuite/g++.dg/warn/ctor1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/testsuite/ChangeLog

Comment 3 Jason Merrill 2008-04-08 17:50:42 UTC
Subject: Bug 35734

Author: jason
Date: Tue Apr  8 17:49:56 2008
New Revision: 134099

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134099
Log:
        PR c++/35734
        * class.c (type_has_user_nondefault_constructor): A template
        counts as a nondefault constructor.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/g++.dg/warn/ctor1.C
      - copied unchanged from r133987, trunk/gcc/testsuite/g++.dg/warn/ctor1.C
Modified:
    branches/gcc-4_3-branch/gcc/cp/ChangeLog
    branches/gcc-4_3-branch/gcc/cp/class.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 4 Jakub Jelinek 2008-04-09 14:25:43 UTC
Fixed.