[PATCH] Fix a couple of fold checking bugs

Mark Mitchell mark@codesourcery.com
Wed Apr 13 04:23:00 GMT 2005


Andrew Pinski wrote:
> There are two problems here.
> First is on types TYPE_CONTAINS_PLACEHOLDER_INTERNAL is allowed to change,
> it is just a cache, the problem can be see with the following C++ code:
> int
> __finite (double __x) throw ()
> {
>   return (__extension__
>    (((((union { double __d; int __i[2]; }) {__d: __x}).__i[1]
>       | 0x800fffffu) + 1) >> 31));
> }
> 
> Note this is also a 4.0 regression.
> 
> The second is that we could just blow the stack right out for TREE_LIST
> with constructors of huge arrays.  This is seen in a bootstrap on
> powerpc-darwin when building insn-attrtab.o in stage2.  The way to fix this
> is to add a label and make us do tail recursion by hand.
> 
> OK for the mainline and for 4.0.1 after
> 4.0 branches reopen? Bootstrapped and tested on
> powerpc-darwin.

This is OK.

However, it would be cleaner to code this as:

do
   {
   ...
   }
/* We do not recur in the TREE_LIST case in order to avoid overflowing 
the stack when processing long lists.  */
while (TREE_CODE (x) == TREE_LIST ? (x = TREE_CHAIN (x)) : NULL_TREE);

-- 
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304



More information about the Gcc-patches mailing list