Member: const int val[2]; Constructor: Foo::Foo (...) : val((int[]) {...}) results in: init.cpp: In constructor `Foo::Foo(int, int)': init.cpp:12: Internal compiler error in build_modify_expr, at cp/typeck.c:5516 works fine with Constructor: Foo::Foo (...) : foo((const int[]) {...}) (i don't understand why i need the casting, but syntax error without...)
Created attachment 4140 [details] produces ICE. would work fine with "(const int[])" in initalization list I would be glad if sombody can tell me why I need the casting operator when initializing arrays. What do I make wrong?
btw. I use Debian. # gcc -v -c init.cpp ....... GNU CPP version 3.2.3 20030415 (Debian prerelease) (cpplib) (i386 Linux/ELF) GNU C++ version 3.2.3 20030415 (Debian prerelease) (i386-linux) compiled by GNU C version 3.2.3 20030415 (Debian prerelease).
I see it on the mainline (20030601), 3.3.1 (20030526), 3.2.3, 3.0.4 but I do not get an ICE but an error on 2.95.3 so this is a regression: tin:~/src/gnu/gcctest>gcc pr11063.cc pr11063.cc: In constructor `Foo::Foo(int, int)': pr11063.cc:13: internal compiler error: in build_modify_expr, at cp/typeck.c: 5395 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. tin:~/src/gnu/gcctest>~/ia32_linux_gcc3_3/bin/gcc pr11063.cc pr11063.cc: In constructor `Foo::Foo(int, int)': pr11063.cc:13: internal compiler error: in build_modify_expr, at cp/typeck.c: 5202 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. tin:~/src/gnu/gcctest>~/ia32_linux_gcc3_2/bin/gcc pr11063.cc pr11063.cc: In constructor `Foo::Foo(int, int)': pr11063.cc:13: Internal compiler error in build_modify_expr, at cp/typeck.c: 5516 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. tin:~/src/gnu/gcctest>~/ia32_linux_gcc3_0/bin/gcc pr11063.cc pr11063.cc: In constructor `Foo::Foo(int, int)': pr11063.cc:13: Internal compiler error in build_modify_expr, at cp/typeck.c: 5627 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions. tin:~/src/gnu/gcctest>~/ia32_linux_gcc2_95//bin/gcc pr11063.cc pr11063.cc: In method `Foo::Foo(int, int)': pr11063.cc:13: incompatible types in assignment of `int[2]' to `const int[2]'
Postponed until GCC 3.3.2.
From Phil's regression hunter: : Search converges between 2000-12-31-trunk (#0) and 2001-01-07-trunk (#1).
On the mainline (20030802) with checking turned off, GCC accepts this code.
Is this code really invalid as a gcc extension (from C99) of style C99 inits for structs/ arrays is being use?
The regression (ICE) in PR 11063 was introduced or exposed by this patch: --- gcc/gcc/cp/ChangeLog --- 2001-01-03 Jason Merrill <jason@redhat.com> * init.c (build_default_init): New fn. (perform_member_init): Split out from here. (build_new_1): Use it. Simplify initialization logic. (build_vec_init): Take an array, rather than a pointer and maxindex. Speed up simple initializations. Don't clean up if we're assigning. * cp-tree.h: Adjust. * decl2.c (do_static_initialization): Remove TREE_VEC case. * parse.y (new_initializer): Return void_zero_node for (). * typeck.c (build_modify_expr): Handle getting a CONSTRUCTOR. * typeck2.c (digest_init): Only complain about user-written CONSTRUCTORs. The regression hunt took place on i686-pc-linux-gnu using this test case, included here because it's slightly different from the one in the attachment: class Foo { private: const int val_[2]; public: Foo(int, int); }; Foo::Foo(int v0, int v1) : val_((int[]) {v0, v1}) { } Before this patch the test case got these messages: 11063.C: In constructor `Foo::Foo(int, int)': 11063.C:12: incompatible types in assignment of `int[2]' to `const int[2]' With this test case I get the same ICE with a recent mainline compiler built with and without checking disabled.
Subject: Bug 11063 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: jason@gcc.gnu.org 2003-10-14 20:45:42 Modified files: gcc/cp : ChangeLog tree.c typeck.c Log message: PR c++/11878 * tree.c (build_target_expr_with_type): Call force_rvalue for classes with non-trivial copy ctors. PR c++/11063 * typeck.c (build_modify_expr): Call convert rather than abort. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.214&r2=1.3076.2.215 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.307.2.4&r2=1.307.2.5 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.436.2.17&r2=1.436.2.18
Subject: Bug 11063 CVSROOT: /cvs/gcc Module name: gcc Changes by: jason@gcc.gnu.org 2003-10-14 20:46:27 Modified files: gcc/cp : ChangeLog tree.c typeck.c Log message: PR c++/11878 * tree.c (build_target_expr_with_type): Call force_rvalue for classes with non-trivial copy ctors. PR c++/11063 * typeck.c (build_modify_expr): Call convert rather than abort. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3729&r2=1.3730 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&r1=1.350&r2=1.351 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.506&r2=1.507
Subject: Bug 11063 CVSROOT: /cvs/gcc Module name: gcc Changes by: jason@gcc.gnu.org 2003-10-14 20:46:45 Added files: gcc/testsuite/g++.dg/ext: complit1.C Log message: PR c++/11063 * typeck.c (build_modify_expr): Call convert rather than abort. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/complit1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed for 3.3.2 and 3.4
This doesn't seem completely fixed. I'm seeing the following excess errors on hppa2.0w-hp-hpux11.11 (3.4 checking on): Excess errors: /xxx/gnu/gcc-3.3/gcc/gcc/testsuite/g++.dg/ext/complit1.C:13: error: ISO C++ forbids compound-literals /xxx/gnu/gcc-3.3/gcc/gcc/testsuite/g++.dg/ext/complit1.C:14: error: conversion from `int[2]' to non-scalar type `const int[2]' requested
Thanks, I've fixed the testcase.