Bug 17396 - [4.0 Regression] ICE in tree-int-cst at -O0
Summary: [4.0 Regression] ICE in tree-int-cst at -O0
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.0.0
: P2 critical
Target Milestone: 4.0.0
Assignee: Richard Henderson
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2004-09-10 13:54 UTC by Steven Bosscher
Modified: 2018-06-02 04:06 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-09-10 22:13:12


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Bosscher 2004-09-10 13:54:59 UTC
An ICE from Ruby, on at least ia64 and amd64, with and without optimization:  
  
struct sigcontext  
{  
  unsigned long int sc_gr;  
};  
  
#define N (((char *) &((struct sigcontext *) 0)->sc_gr) - (char *) 0)  
  
struct tag  
{  
  unsigned long _pad[N];  
};  
  
static struct tag *prot_tag;  
  
void  
error_print (void)  
{  
  struct tag _tag;  
  prot_tag = &_tag;  
}  
  
The interesting thing is that this ICEs in tree_low_cst, which  
is supposed to extract an integer from an INTEGER_CST tree, but  
the tree that we give it is not an INTEGER_CST at all:  
  
(gdb) p debug_generic_expr (t)  
(long unsigned int<D4>) &0B->sc_gr<D1465> * 8  
$3 = void
Comment 1 Andrew Pinski 2004-09-10 14:28:45 UTC
I wonder why Ruby does not use the compiler's defintion of offsetof.
Comment 2 Steven Bosscher 2004-09-10 19:57:37 UTC
Just for clarity, this happens with the _C_ compiler. 
 
The C++ front end gives an error, as expected: 
t.i:10: error: size of array `_pad' is not an integral constant-expression 
 
 
Comment 3 Andrew Pinski 2004-09-10 22:13:12 UTC
: Search converges between 2004-09-02-trunk (#532) and 2004-09-04-trunk (#533).
Comment 4 Andrew Pinski 2004-09-10 22:15:11 UTC
I almos think it was this patch which caused this ICE:
2004-09-01  Richard Henderson  <rth@redhat.com>

        PR middle-end/17258
        * calls.c (initialize_argument_information): Tighten pass-through
        conditions for pass-by-reference.  Remove dead TARGET_EXPR code.
        Use build_fold_addr_expr.
        (emit_library_call_value_1): Use build_fold_addr_expr.  Remove code
        that assumes ADDR_EXPR allocates stack space.
        * fold-const.c (build_fold_addr_expr_with_type): Look through
        WITH_SIZE_EXPR.
Comment 5 Richard Henderson 2004-09-10 22:41:42 UTC
No, this is &a.b fallout.
Comment 6 CVS Commits 2004-09-11 17:03:10 UTC
Subject: Bug 17396

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rth@gcc.gnu.org	2004-09-11 17:03:01

Modified files:
	gcc            : ChangeLog c-typeck.c 

Log message:
	PR c/17396
	* c-typeck.c (build_unary_op): Add legacy offsetof hack.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.5389&r2=2.5390
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&r1=1.371&r2=1.372

Comment 7 Richard Henderson 2004-09-11 17:13:03 UTC
http://gcc.gnu.org/ml/gcc-patches/2004-09/msg01101.html