[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

ICE at cp/cp-lang.c:130 for struct initialization



>Submitter-Id:	net
>Originator:	Marko Makela
>Organization:	Helsinki University of Technology
>Confidential:	no
>Synopsis:	initializing a struct having a class component fails
>Severity:	serious
>Priority:	medium
>Category:	c++
>Class:		ice-on-legal-code
>Release:	3.2.1 20020830 (Debian prerelease) (Debian testing/unstable)
>Environment:
System: Linux siphon 2.4.3 #4 Mon Apr 9 12:53:30 EEST 2001 i686 unknown unknown GNU/Linux
Architecture: i686

	
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: /mnt/data/gcc-3.1/gcc-3.2-3.2.1ds0/src/configure -v --enable-languages=c,c++,java,f77,proto,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-java-gc=boehm --enable-objc-gc i386-linux
>Description:
	If a struct has a class-valued component, initializing an instance
	of the struct by using a brace-delimited initialization expression
	triggers an ICE in cp_expr_size, at cp/cp-lang.c:130.  It seems that
	there must be an explicit declaration of both a copy constructor and
	an assignment operator for the class in order for the bug to occur.
>How-To-Repeat:
	The following code is a reduced test case that fails on this version
	of the compiler.  It seems to work in g++ (GCC) 3.2.1 20020905
	(prerelease) on SunOS 5.8, so you may want to ignore this report.

class C
{
public:
  C ();
  C (const class C& old);
  class C& operator= (const class C& old);
};

struct s
{
  class C c;
};

void
f (void)
{
  class C c;
  struct s s = { c };
}

>Fix:	Declare the struct with a pointer or a reference instead, or
	do not declare a copy constructor or operator=() for the class.



Reply to: