This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gcc-3.0 branch digest_init


digest_init was calling initializer_constant_valid_p with an expression
that violated icvp's assumption that VALUE has been folded as much as
possible.

testcase:

$ cat consinit.i
extern void _text;
static unsigned long x = (unsigned long) &_text - 0x10000000L - 1;

$ gcc_new/gcc/xgcc -v -S consinit.i
[snip]
GNU C version 3.0 20010315 (prerelease) (hppa-linux)
        compiled by GNU C version 2.95.2 19991024 (release).
consinit.i:2: warning: initializer element is not computable at load time
consinit.i:2: Internal error: Segmentation fault

Possible fix:
	* c-typeck.c (digest_init): Fold init expression.

--- gcc/c-typeck.c~	Fri Mar 16 09:57:01 2001
+++ gcc/c-typeck.c	Sat Mar 17 16:44:32 2001
@@ -4662,7 +4662,7 @@ digest_init (type, init, require_constan
      int require_constant, constructor_constant;
 {
   enum tree_code code = TREE_CODE (type);
-  tree inside_init = init;
+  tree inside_init = fold (init);
 
   if (type == error_mark_node
       || init == error_mark_node

Alan Modra
-- 
Linuxcare


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]