Bug 21105 - [4.0/4.1 Regression] Compiling of large array fails
Summary: [4.0/4.1 Regression] Compiling of large array fails
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.0.2
Assignee: Not yet assigned to anyone
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-invalid-code, patch
Depends on:
Blocks:
 
Reported: 2005-04-19 13:02 UTC by Martin Kögler
Modified: 2005-08-16 20:36 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.0 3.3.3 4.0.2 4.1.0
Known to fail: 4.0.0 3.0.4
Last reconfirmed: 2005-06-26 17:42:28


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Kögler 2005-04-19 13:02:48 UTC
Compiling
void
foo ()
{
  float c[204800000][4];
}

fails with
t3.c: In function 'foo':
t3.c:16: internal compiler error: in tree_low_cst, at tree.c:3846

All current CVS versions (4.X fail).
At least some 3.x versions are not affected
GCC 2.96 shows an other error.

Affected Versions, which I tested:
4.1.0 20050416
4.1.0 20050302
2.96 20000731 (Red Hat Linux 7.2 2.96-112.7.2)

Non Affected Version:
3.3.3 20040412 (Red Hat Linux 3.3.3-7)
Comment 1 Andrew Pinski 2005-04-19 13:08:30 UTC
Confirmed, this is most likely caused by the tree-ssa merge.
Comment 2 Andrew Pinski 2005-05-02 21:55:12 UTC
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-05/msg00121.html>.
Comment 3 Andrew Pinski 2005-07-25 15:50:14 UTC
Hmm, Jim posted a patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-05/msg00377.html>  but 
never applied it.
Comment 4 wilson@specifix.com 2005-08-16 00:47:25 UTC
Subject: Re:  [4.0/4.1 Regression] Compiling of large
 array fails

pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-25 15:50 -------
> Hmm, Jim posted a patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-05/msg00377.html>  but 
> never applied it.

I never finished my patch.  I was hoping someone else would help finish
it.  Since it is my patch, I'll follow up on this.

The first thing I did here is grep the entire tree for
  TREE_OVERFLOW (TYPE_SIZE (...))
since all such occurances are broken.  I found 3.  One in the C front
end (this bug), one in the C++ front end, and one in the Ada front end.

I can't create a testcase for the Ada bug, nor can I at the moment build
the Ada front end, so there is not much I can do there other than maybe
create a new bug report for it and insert the obvious patch.

The C++ code is identical to the C code, so the same testcase and patch
work here.  Unfortunately, there is a problem.  I get
tmp.cc:13: error: size of array ‘array’ is too large
tmp.cc:17: error: ‘array’ was not declared in this scope
The first error is correct, the second one isn't.  Or at least I assume
it isn't.  I'm not qualified to comment on that, nor am I qualified to
fix it.  So, um, I guess I am creating yet another new bug report for that.

For the C front end, I have a patch that I believe is correct, and I
have a small testcase that I think is reasonably portable.  I need to
drop my testcase into the testsuite with dg annotations, and test it all
with a bootstrap and make check.
Comment 5 GCC Commits 2005-08-16 18:24:14 UTC
Subject: Bug 21105

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	wilson@gcc.gnu.org	2005-08-16 18:23:59

Modified files:
	gcc            : ChangeLog c-decl.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: large-size-array.c 

Log message:
	Emit an error for too large arrays instead of an ICE.
	PR tree-optimization/21105
	* c-decl.c (grokdeclarator): Use TYPE_SIZE_UNIT not TYPE_SIZE in
	TREE_OVERFLOW check.
	* gcc.dg/large-size-array.c: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9745&r2=2.9746
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&r1=1.680&r2=1.681
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5928&r2=1.5929
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/large-size-array.c.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 6 GCC Commits 2005-08-16 20:34:30 UTC
Subject: Bug 21105

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	wilson@gcc.gnu.org	2005-08-16 20:34:21

Modified files:
	gcc            : ChangeLog c-decl.c 

Log message:
	Fix ICE that occurs with too large array.
	PR tree-optimization/21105
	* c-decl.c (grokdeclarator): Use TYPE_SIZE_UNIT not TYPE_SIZE in
	TREE_OVERFLOW check.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.371&r2=2.7592.2.372
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.630.6.15&r2=1.630.6.16

Comment 7 Jim Wilson 2005-08-16 20:36:38 UTC
The C front end bug is fixed on mainline and the gcc-4.0.x branch.  The C++ and
Ada front end bugs have their own PRs now.
Comment 8 GCC Commits 2005-08-22 23:52:31 UTC
Subject: Bug 21105

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	wilson@gcc.gnu.org	2005-08-22 23:52:24

Modified files:
	gcc/cp         : ChangeLog decl.c 

Log message:
	Partial fix for too large arrays.
	PR tree-optimization/21105
	* decl.c (grokdeclarator): Use TYPE_SIZE_UNIT not TYPE_SIZE for
	array size check.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4854&r2=1.4855
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1419&r2=1.1420