This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

Re: compile/20011114-1.c, any clues?


... so I sat down and poked around a bit and now I know what's wrong
(assuming that the test case is correct code and should be accepted).

Recall that the initializer was (unsigned int) &_text - 0x10000000L - 1.

digest_init gets this tree for the initializer:

 <plus_expr 0x4014a620
    type <integer_type 0x40146488 long unsigned int>
    constant
    arg 0 <nop_expr 0x4014e7b0 type <integer_type 0x40146488 long unsigned int>
        constant
        arg 0 <nop_expr 0x4014e798 type <integer_type 0x401463a0 unsigned int>
            constant
            arg 0 <convert_expr 0x4014e780 type <integer_type 0x4014632c int>
                constant
                arg 0 <addr_expr 0x4014e768 type <pointer_type 0x40148828>
                    constant arg 0 <var_decl 0x401602b8 _text>>>>>
    arg 1 <minus_expr 0x4014a600 type <integer_type 0x40146488 long unsigned int>
        constant
        arg 0 <negate_expr 0x4014e810 type <integer_type 0x40146488 long unsigned int>
            constant
            arg 0 <integer_cst 0x4014a560 constant 268435456>>
        arg 1 <integer_cst 0x4014a5a0 constant 1>>>

This is an incompletely folded tree.  The entire of arg 1 of the outer
PLUS_EXPR should have been collapsed down to 

   <integer_cst 0x4014a660
      type <integer_type 0x40146488 long unsigned int> 
      constant 4026531839>>

which is what I get by calling fold() by hand from the debugger,
working out from the NEGATE_EXPR.  Sticking that back into the
PLUS_EXPR causes digest_init to complete successfully and produce the
correct result.

The missing fold is in fold-const.c::negate_expr():

===================================================================
Index: fold-const.c
--- fold-const.c	2001/12/15 20:31:04	1.179
+++ fold-const.c	2001/12/16 21:05:42
@@ -1388,7 +1388,7 @@ negate_expr (t)
       break;
     }
 
-  return convert (type, build1 (NEGATE_EXPR, TREE_TYPE (t), t));
+  return convert (type, fold (build1 (NEGATE_EXPR, TREE_TYPE (t), t)));
 }
 
 /* Split a tree IN into a constant, literal and variable parts that could be

I will apply this as an obvious bugfix if it survives a bootstrap and
causes no new regressions.

zw


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