Bug 41935 - [4.4/4.5 Regression] ICE : tree check: expected integer_cst, have nop_expr in int_cst_value, at tree.c:8301
Summary: [4.4/4.5 Regression] ICE : tree check: expected integer_cst, have nop_expr in...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.4.3
: P3 critical
Target Milestone: 4.4.3
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code
: 41945 41955 41968 (view as bug list)
Depends on:
Blocks: 41945
  Show dependency treegraph
 
Reported: 2009-11-04 07:28 UTC by macius bat
Modified: 2009-11-06 22:51 UTC (History)
5 users (show)

See Also:
Host: x86_64-pc-linux
Target: x86_64-pc-linux
Build: x86_64-pc-linux
Known to work:
Known to fail:
Last reconfirmed: 2009-11-04 09:35:32


Attachments
the source (164.77 KB, application/x-gzip)
2009-11-04 07:29 UTC, macius bat
Details
gcc45-pr41935.patch (1.07 KB, patch)
2009-11-04 10:37 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description macius bat 2009-11-04 07:28:28 UTC
$gcc -v
gcc version 4.4.3 20091104 (prerelease) (GCC) 

$gcc -c pid.c
kernel/pid.c: In function 'find_pid_ns':
kernel/pid.c:299: internal compiler error: tree check: expected integer_cst, have nop_expr in int_cst_value, at tree.c:8301
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 macius bat 2009-11-04 07:29:36 UTC
Created attachment 18961 [details]
the source
Comment 2 Jakub Jelinek 2009-11-04 09:27:50 UTC
Seems to be caused by the PR38699 changes.  Looking into it.
Comment 3 Jakub Jelinek 2009-11-04 09:35:31 UTC
Shorter testcase:
/* PR middle-end/41935 */

extern void abort (void);
struct A { int a; int b[10]; };

int
foo (struct A *p)
{
  return __builtin_offsetof (struct A, b[p->a]);
}

int
main ()
{
  struct A a;
  a.a = 7;
  if (foo (&a) != 7 * sizeof (int) + __builtin_offsetof (struct A, b))
    abort ();
  a.a = 2;
  if (foo (&a) != 2 * sizeof (int) + __builtin_offsetof (struct A, b))
    abort ();
  return 0;
}
Comment 4 Jakub Jelinek 2009-11-04 10:37:37 UTC
Created attachment 18962 [details]
gcc45-pr41935.patch

Patch I'm going to bootstrap/regtest.
Comment 5 Andrew Pinski 2009-11-06 08:33:57 UTC
*** Bug 41945 has been marked as a duplicate of this bug. ***
Comment 6 Jakub Jelinek 2009-11-06 08:46:58 UTC
Subject: Bug 41935

Author: jakub
Date: Fri Nov  6 08:46:45 2009
New Revision: 153962

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153962
Log:
	PR middle-end/41935
	* c-common.c (fold_offsetof_1) <case ARRAY_REF>: Don't crash for VLAs
	or non-constant index, allow index one past the last element and
	allow exceeding array bound in arrays that might be used as flexible
	array members.

	* gcc.dg/pr41935.c: New test.
	* c-c++-common/pr41935.c: New test.
	* c-c++-common/builtin-offsetof.c (f0): Allow index one past the last
	element.
	* gcc.c-torture/execute/pr41935.c: New test.

Added:
    trunk/gcc/testsuite/c-c++-common/pr41935.c
    trunk/gcc/testsuite/gcc.c-torture/execute/pr41935.c
    trunk/gcc/testsuite/gcc.dg/pr41935.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-common.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/c-c++-common/builtin-offsetof.c

Comment 7 Jakub Jelinek 2009-11-06 09:22:15 UTC
Fixed.  On the 4.4 branch by http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153944
- partial reversion of the patch that introduced this problem.
Comment 8 Jakub Jelinek 2009-11-06 12:42:22 UTC
*** Bug 41968 has been marked as a duplicate of this bug. ***
Comment 9 Richard Biener 2009-11-06 22:51:14 UTC
*** Bug 41955 has been marked as a duplicate of this bug. ***
Comment 10 hjl@gcc.gnu.org 2009-11-20 14:50:43 UTC
Subject: Bug 41935

Author: hjl
Date: Fri Nov 20 14:49:22 2009
New Revision: 154366

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154366
Log:
2009-11-20  H.J. Lu  <hongjiu.lu@intel.com>

	Backport from mainline:
	2009-11-18  Alexandre Oliva  <aoliva@redhat.com>

	PR debug/41926
	* gcc.dg/vect/vect-debug-pr41926.c: New.

	2009-11-16  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/42055
	* g++.dg/template/crash92.C: New.

	2009-11-08  Richard Guenther  <rguenther@suse.de>

	PR rtl-optimization/41928
	* gfortran.dg/pr41928.f90: New testcase.

	2009-11-06  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/41935
	* gcc.dg/pr41935.c: New test.
	* c-c++-common/pr41935.c: New test.
	* gcc.c-torture/execute/pr41935.c: New test.

	2009-11-04  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/41919
	* gcc.c-torture/execute/pr41919.c: New testcase.

	2009-11-03  Tobias Burnus  <burnus@net-b.de>

	PR fortran/41907
	* gfortran.dg/missing_optional_dummy_6.f90: New test.

	2009-11-02  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/41750
	* gcc.c-torture/execute/pr41750.c: New test.

	2009-11-02  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/41841
	* gcc.dg/pr41841.c: New test.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/c-c++-common/pr41935.c
      - copied unchanged from r154365, trunk/gcc/testsuite/c-c++-common/pr41935.c
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/crash92.C
      - copied unchanged from r154365, trunk/gcc/testsuite/g++.dg/template/crash92.C
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr41750.c
      - copied unchanged from r154365, trunk/gcc/testsuite/gcc.c-torture/execute/pr41750.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr41919.c
      - copied unchanged from r154365, trunk/gcc/testsuite/gcc.c-torture/execute/pr41919.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr41935.c
      - copied unchanged from r154365, trunk/gcc/testsuite/gcc.c-torture/execute/pr41935.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr41841.c
      - copied unchanged from r154365, trunk/gcc/testsuite/gcc.dg/pr41841.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr41935.c
      - copied unchanged from r154365, trunk/gcc/testsuite/gcc.dg/pr41935.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/vect/vect-debug-pr41926.c
      - copied unchanged from r154365, trunk/gcc/testsuite/gcc.dg/vect/vect-debug-pr41926.c
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/missing_optional_dummy_6.f90
      - copied unchanged from r154365, trunk/gcc/testsuite/gfortran.dg/missing_optional_dummy_6.f90
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/pr41928.f90
      - copied unchanged from r154365, trunk/gcc/testsuite/gfortran.dg/pr41928.f90
Modified:
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog