Bug 27409 - [4.1 Regression] ICE in get_constraint_for_component_ref
Summary: [4.1 Regression] ICE in get_constraint_for_component_ref
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: 4.1.1
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: 26678
  Show dependency treegraph
 
Reported: 2006-05-03 15:46 UTC by Michael Matz
Modified: 2006-05-09 14:33 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.0 4.0.3
Known to fail: 4.1.0
Last reconfirmed: 2006-05-03 16:06:26


Attachments
patch (849 bytes, patch)
2006-05-03 16:13 UTC, Richard Biener
Details | Diff
patch relative to 4.1 (776 bytes, patch)
2006-05-03 17:54 UTC, Michael Matz
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Matz 2006-05-03 15:46:31 UTC
The below testcase ICEs in get_constraint_for_component_ref when compiled
with -O1 or beyond on x86_64.  Richard mentions that it also fails with
trunk.

---------------------------------------
/* compile with gcc -c -Os -o foo.o foo.c */

typedef struct {
        struct { } z;
} thang_t;
struct widget {
        struct widget *p, *q;
};
typedef struct thing {
        struct widget   x;
} thing_t;
struct {
        int             a;
        int             b;
        int             c;
        int             d;
        int             e;
        thang_t         f;
        thing_t         g;
} my_struct;
static void foo(thang_t *r)
{ splat(r);}
void function(int blaz)
{ foo(&my_struct.f);}
---------------------------------------
Comment 1 Richard Biener 2006-05-03 16:05:15 UTC
Confirmed.  We access a zero-sized part of the structure:

    arg 1 <field_decl 0x2a959f2180 f type <record_type 0x2a959dfb00 thang_t>
        BLK file t.c line 16 size <integer_cst 0x2a958ab750 0> unit size <integer_cst 0x2a95891720 0>
        align 8 offset_align 128
        offset <integer_cst 0x2a958ab0f0 constant invariant 16>
        bit offset <integer_cst 0x2a95891bd0 constant invariant 32> context <record_type 0x2a959dfe70>
        chain <field_decl 0x2a959f2240 g type <record_type 0x2a959dfdc0 thing_t>
            BLK file t.c line 17
            size <integer_cst 0x2a958ab0c0 constant invariant 128> unit size <integer_cst 0x2a958ab0f0 16>
            align 64 offset_align 128 offset <integer_cst 0x2a958ab0f0 16>
            bit offset <integer_cst 0x2a95891d80 constant invariant 64> context <record_type 0x2a959dfe70>>>>

The following testcase also ICEs on 32bit targets:

typedef struct {
        struct { } z;
} thang_t;
struct {
        short           e;
        thang_t         f;
        int g;
} my_struct;
void function(int blaz)
{ thang_t *fp = &my_struct.f; foo(fp);}

the important thing is that there has to be padding after e and the zero-sized f.
Comment 2 Richard Biener 2006-05-03 16:06:26 UTC
I have a fix.
Comment 3 Richard Biener 2006-05-03 16:13:18 UTC
Created attachment 11367 [details]
patch

Patch to be tested (Micha, can you do this?).
Comment 4 Michael Matz 2006-05-03 17:53:26 UTC
Yes.  I'm testing it for trunk and 4.1 on a couple platforms.
Comment 5 Michael Matz 2006-05-03 17:54:26 UTC
Created attachment 11368 [details]
patch relative to 4.1

This is the same patch adjusted for 4.1.
Comment 6 Richard Biener 2006-05-07 21:04:02 UTC
Subject: Bug 27409

Author: rguenth
Date: Sun May  7 21:03:55 2006
New Revision: 113607

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113607
Log:
2006-05-07  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/27409
	* tree-ssa-structalias.c (get_constraint_for_component_ref):
	Do not try to find zero-sized subvars.

	* gcc.dg/torture/pr27409.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr27409.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-structalias.c

Comment 7 Andrew Pinski 2006-05-08 06:52:59 UTC
Fixed at least on the mainline.
Comment 8 Richard Biener 2006-05-09 14:33:33 UTC
Subject: Bug 27409

Author: rguenth
Date: Tue May  9 14:33:26 2006
New Revision: 113652

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113652
Log:
2006-05-09  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/27409
	* tree-ssa-structalias.c (get_constraint_for_component_ref):
	Do not try to find zero-sized subvars.

	* gcc.dg/torture/pr27409.c: New testcase.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/torture/pr27409.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/tree-ssa-structalias.c

Comment 9 Richard Biener 2006-05-09 14:33:43 UTC
Fixed.
Comment 10 patchapp@dberlin.org 2006-05-15 19:32:45 UTC
Subject: Bug number PR27409

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-05/msg00153.html