Bug 11063 - [3.3/3.4 Regression] ICE on parsing initialization list of const array member
Summary: [3.3/3.4 Regression] ICE on parsing initialization list of const array member
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2.2
: P2 normal
Target Milestone: 3.3.2
Assignee: Jason Merrill
URL:
Keywords: accepts-invalid, ice-checking, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2003-06-02 12:15 UTC by Bernhard Ibertsberger
Modified: 2004-01-17 04:22 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-08-03 17:31:01


Attachments
produces ICE. would work fine with "(const int[])" in initalization list (148 bytes, text/plain)
2003-06-02 12:20 UTC, Bernhard Ibertsberger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard Ibertsberger 2003-06-02 12:15:01 UTC
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...)
Comment 1 Bernhard Ibertsberger 2003-06-02 12:20:56 UTC
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?
Comment 2 Bernhard Ibertsberger 2003-06-02 12:24:47 UTC
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).

Comment 3 Andrew Pinski 2003-06-02 12:27:41 UTC
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]'
Comment 4 Mark Mitchell 2003-07-11 22:19:28 UTC
Postponed until GCC 3.3.2.
Comment 5 Andrew Pinski 2003-07-23 19:43:42 UTC
From Phil's regression hunter:
: Search converges between 2000-12-31-trunk (#0) and 2001-01-07-trunk (#1). 
Comment 6 Andrew Pinski 2003-08-03 17:31:01 UTC
On the mainline (20030802) with checking turned off, GCC accepts this code.
Comment 7 Andrew Pinski 2003-08-05 02:23:25 UTC
Is this code really invalid as a gcc extension (from C99) of style C99 inits for structs/
arrays is being use?
Comment 8 janis187 2003-08-05 22:45:11 UTC
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.
Comment 9 CVS Commits 2003-10-14 20:45:49 UTC
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

Comment 10 CVS Commits 2003-10-14 20:46:31 UTC
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

Comment 11 CVS Commits 2003-10-14 20:46:49 UTC
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

Comment 12 Andrew Pinski 2003-10-14 20:49:48 UTC
Fixed for 3.3.2 and 3.4
Comment 13 John David Anglin 2003-10-17 01:57:20 UTC
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
Comment 14 Jason Merrill 2003-10-17 04:57:13 UTC
Thanks, I've fixed the testcase.