See <http://gcc.gnu.org/ml/gcc/2005-06/msg00059.html> for the full description.
Confirmed based on the whole thread.
hmm, I can't test the 4.1 bootstrap with -fwrapv due to xgcc error. make -C obj-amd64-pld-linux \ bootstrap \ GCJFLAGS="%{rpmcflags}" \ BOOT_ADAFLAGS="%{rpmcflags} -fwrapv" \ GNATLIBCFLAGS="-O1 -fwrapv" \ BOOT_CFLAGS="%{rpmcflags}" \ STAGE1_CFLAGS="%{rpmcflags} -O0" \ LDFLAGS_FOR_TARGET="%{rpmldflags}" (...) stage1/xgcc -Bstage1/ -B/usr/amd64-pld-linux/bin/ -c -O1 -fwrapv -I- -I. -Iada -I../../gcc/ada ../../gcc/ada/ada.ads -o ada/ada.o ada.ads:16:01: language defined units may not be recompiled make[2]: *** [ada/ada.o] Error 1
> hmm, I can't test the 4.1 bootstrap with -fwrapv due to xgcc error. Try this to enable -fwrapv by default: --- misc.c 01 Jun 2005 10:00:47 +0200 1.102 +++ misc.c 08 Jun 2005 14:58:25 +0200 @@ -339,6 +339,8 @@ gnat_init_options (unsigned int argc, co /* Uninitialized really means uninitialized in Ada. */ flag_zero_initialized_in_bss = 0; + flag_wrapv = 1; + return CL_Ada; }
(In reply to comment #4) as the thread said this is only a workaround.
with this workaround stage3 fails :/ (...) ../../xgcc -B../../ -c -g -O2 -fPIC -W -Wall -gnatpg a-ncelfu.ads -o a-ncelfu.o a-ngcefu.adb: In function 'Ada.Numerics.Complex_Elementary_Functions.Sqrt': a-ngcefu.adb:578: error: Statement marked for throw in middle of block. D.1921_90 = ada__numerics__complex_types__compose_from_cartesian (D.1920_89, 0.0); a-ngcefu.adb:578: error: Statement marked for throw in middle of block. D.1928_86 = ada__numerics__complex_types__compose_from_cartesian (0.0, D.1927_85); a-ngcefu.adb:578: error: Statement marked for throw in middle of block. D.1931_78 = ada__numerics__complex_types__compose_from_cartesian (r_xD.1914_73, r_xD.1914_73); a-ngcefu.adb:578: error: Statement marked for throw in middle of block. D.1933_76 = ada__numerics__complex_types__compose_from_cartesian (r_xD.1914_73, D.1932_75); a-ngcefu.adb:578: error: Statement marked for throw in middle of block. D.1948_55 = ada__numerics__complex_types__compose_from_cartesian (r_xD.1914_2, r_yD.1915_4); a-ngcefu.adb:578: error: Statement marked for throw in middle of block. D.1950_21 = ada__numerics__complex_types__Odivide__3 (xD.370_6, 4.0e+0); a-ngcefu.adb:578: error: Statement marked for throw in middle of block. D.1953_25 = ada__numerics__complex_types__compose_from_cartesian (D.1952_24, D.1951_22); a-ngcefu.adb:578: error: Statement marked for throw in middle of block. D.1948_45 = ada__numerics__complex_types__compose_from_cartesian (r_xD.1914_34, r_yD.1915_5); +===========================GNAT BUG DETECTED==============================+ | 4.1.0 20050610 (experimental) (i686-pld-linux-gnu) verify_stmts failed. | | Error detected at a-ncelfu.ads:23:1 | | Please submit a bug report; see http://gcc.gnu.org/bugs.html. | | Use a subject line meaningful to you and us to track the bug. | | Include the entire contents of this bug box in the report. | | Include the exact gcc or gnatmake command that you entered. | | Also include sources listed below in gnatchop format | | (concatenated together with no headers between files). | +==========================================================================+ (...) raised TYPES.UNRECOVERABLE_ERROR : comperr.adb:381
(In reply to comment #6) > with this workaround stage3 fails :/ Yes that is PR 21994 and then we are blocked by 21923.
Well, it seems to me that the culprit is fold, no? else if (!in_gimple_form && TREE_INT_CST_HIGH (arg1) == signed_max_hi && TREE_INT_CST_LOW (arg1) == signed_max_lo && TYPE_UNSIGNED (TREE_TYPE (arg1)) /* signed_type does not work on pointer types. */ && INTEGRAL_TYPE_P (TREE_TYPE (arg1))) { /* The following case also applies to X < signed_max+1 and X >= signed_max+1 because previous transformations. */ if (code == LE_EXPR || code == GT_EXPR) { tree st0, st1; st0 = lang_hooks.types.signed_type (TREE_TYPE (arg0)); st1 = lang_hooks.types.signed_type (TREE_TYPE (arg1)); return fold (build2 (code == LE_EXPR ? GE_EXPR: LT_EXPR, type, fold_convert (st0, arg0), fold_convert (st1, integer_zero_node))); } } (gdb) p debug_tree(arg0) <var_decl 0x556e1d80 J4b type <integer_type 0x556d9144 character sizes-gimplified public visited unsigned QI size <integer_cst 0x556a61f8 constant invariant visited 8> unit size <integer_cst 0x556a6210 constant invariant visited 1> user align 8 symtab 0 alias set -1 precision 8 min <integer_cst 0x556d71e0 0> max <integer_cst 0x556d71f8 255> RM size <integer_cst 0x556a61f8 8> pointer_to_this <pointer_type 0x556d93cc access_character>> unsigned ignored QI file ../../asets.adb line 3 size <integer_cst 0x556a61f8 8> unit size <integer_cst 0x556a6210 1> align 8 context <function_decl 0x556e0144 asets___elabb> initial <integer_cst 0x556d71e0 0>> $13 = void (gdb) p debug_tree(arg1) <integer_cst 0x556e3030 type <integer_type 0x556d9144 character> constant invariant 127> $14 = void (gdb) p code $15 = LE_EXPR
(In reply to comment #8) > Well, it seems to me that the culprit is fold, no? No because Ada front-end is creating: signed_char <= 127 which is always true, removing this from fold would not change the problem as it will still be optimized away.
> No because Ada front-end is creating: > signed_char <= 127 which is always true, removing this from fold would not > change the problem as it will still be optimized away. Where do you see signed_char? The type 0x556d9144 is unsigned.
(In reply to comment #10) > > No because Ada front-end is creating: > > signed_char <= 127 which is always true, removing this from fold would not > > change the problem as it will still be optimized away. > > Where do you see signed_char? The type 0x556d9144 is unsigned. Woops, I must have read something wrong. This is still a bug in the VRP. C Testcase: unsigned char c[0xFF]; void f(void) { unsigned char i; c[128] = 128; i = 0; while (1) { if (((signed char) i) < 0) break; c[i] = ' '; i++; } }
Why does ivcanon/tree-ssa-loop-niter gets this correct (at 128) but VRP cannot.
Still wrong: i_2: VARYING i.0_6: [0, +INF] EQUIVALENCES: { } (0 elements) # i_2 = PHI <0(0), i_9(2)>; <L0>:; i.0_6 = (signed char) i_2; if (i.0_6 < 0) goto <L2>; else goto <L1>;
Still an infinite loop on bootstrap as of LAST_UPDATED Tue Jun 21 20:10:50 UTC 2005 stage2/xgcc -Bstage2/ -B/home/guerby/work/gcc/install/install-20050621T221553/x86_64-unknown-linux-gnu/bin/ -c -g -O2 -gnatpg -gnata -I- -I. -Iada -I/home/guerby/work/gcc/version-head/gcc/ada /home/guerby/work/gcc/version-head/gcc/ada/ada.ads -o ada/ada.o
(In reply to comment #12) > Why does ivcanon/tree-ssa-loop-niter gets this correct (at 128) but VRP cannot. > Wrong. scev fails to tell us that this variable may wrap around.
Testing patch.
Subject: Bug 21959 CVSROOT: /cvs/gcc Module name: gcc Changes by: dnovillo@gcc.gnu.org 2005-06-28 00:52:35 Modified files: gcc : ChangeLog tree-ssa-loop-niter.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg/tree-ssa: pr21959.c Log message: PR 21959 * tree-ssa-loop-niter.c (scev_probably_wraps_p): Handle type casts between unsigned and signed types with different size or precision. testsuite/ChangeLog PR 21959 * gcc.dg/tree-ssa/pr21959.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9246&r2=2.9247 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-loop-niter.c.diff?cvsroot=gcc&r1=2.31&r2=2.32 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5692&r2=1.5693 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/pr21959.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed.
*** Bug 22221 has been marked as a duplicate of this bug. ***