From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 50B573858421; Tue, 20 Dec 2022 14:26:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50B573858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671546378; bh=+qqo0OsTWGcPNquz7/Oda7n8btBqbM6lY5QKYP6oKrE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=RWjGZhOG3GNBjR/Zrf3DtkU02uAehEaDS5CRvEG/zFGYA7XnDu+BZRiBGgrdKwYNg lUoiJU1TxtI76KvIDTxkbdozP+EjFZqazCimAwnykk2O+x5bcy1PnGNkpQPDWZ2mtP wxbGYjuyf3rHBpEFAPAegZJzsh+XDf32dYVil3nY= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug modula2/108121] Failing tests on x86_64-linux-gnu Date: Tue, 20 Dec 2022 14:26:17 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: modula2 X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: gaius at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108121 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- (In reply to Martin Li=C5=A1ka from comment #2) > > gm2.log: FAIL: gm2/pim/pass/TestLong4.mod, -g=20=20 >=20 > And this one fails due to UBSAN (signed integer overflow): >=20 > /dev/shm/objdir/gcc/gm2 -B/dev/shm/objdir2/gcc > /home/marxin/Programming/gcc/gcc/testsuite/gm2/pim/pass/TestLong4.mod -c > /home/marxin/Programming/gcc/gcc/m2/gm2-gcc/m2expr.cc:4037:13: runtime > error: signed integer overflow: 1717986918 + 429496730 cannot be represen= ted > in type 'int' > #0 0x4db49f6 in append_m2_digit > /home/marxin/Programming/gcc/gcc/m2/gm2-gcc/m2expr.cc:4037 > #1 0x4db52c0 in m2expr_interpret_m2_integer > /home/marxin/Programming/gcc/gcc/m2/gm2-gcc/m2expr.cc:4106 > #2 0x4da403c in m2decl_DetermineSizeOfConstant > /home/marxin/Programming/gcc/gcc/m2/gm2-gcc/m2decl.cc:296 > #3 0x4f8879e in GetConstLitType(unsigned int, unsigned int) > (/dev/shm/objdir2/gcc/cc1gm2+0x4f8879e) > #4 0x4f9d0e3 in SymbolTable_MakeConstLit > (/dev/shm/objdir2/gcc/cc1gm2+0x4f9d0e3) > #5 0x4f633a8 in P2SymBuild_BuildNumber > (/dev/shm/objdir2/gcc/cc1gm2+0x4f633a8) > #6 0x4fe4572 in Integer(unsigned int, unsigned int, unsigned int) > (/dev/shm/objdir2/gcc/cc1gm2+0x4fe4572) > #7 0x4fe5076 in Number(unsigned int, unsigned int, unsigned int) > (/dev/shm/objdir2/gcc/cc1gm2+0x4fe5076) > #8 0x4feea69 in Factor(unsigned int, unsigned int, unsigned int) > (/dev/shm/objdir2/gcc/cc1gm2+0x4feea69) The integer overflow is just one thing and could be easily worked around wi= th performing the test_high =3D res_high + add_high; addition in append_m2_digit in unsigned and test_high =3D res_high + add_hi= gh; in append_digit in unsigned HOST_WIDE_INT type, like: test_high =3D (unsigned) res_high + add_high; or so. I must say I'm quite puzzled on the uses of INT_TYPE_SIZE in these functions though, I would have expected it would want instead HOST_BITS_PER_INT and HOST_BITS_PER_WIDE_INT, as that is number of bits on the host that can fit,= and perhaps then depending on INT_TYPE_SIZE decide into which target type it fi= ts. But say if HOST_BITS_PER_WIDE_INT is larger than INT_TYPE_SIZE (pretty much always), then I can't convince myself the routines will do the right thing. That said, I think the error on the test happens much later, LONGCARD on x8= 6_64 seems to be unsigned 64-bit type, so 9223372036854775808 constant certainly fits there, but then: #4 0x0000000001856de7 in make_int_cst (len=3D1, ext_len=3D1) at ../../gcc/tree.cc:2727 #5 0x000000000185268e in build_new_int_cst (type=3D, cst=3D...) at ../../gcc/tree.cc:1456 #6 0x0000000001852c9a in force_fit_type (type=3D, cst=3D..., overflowable=3D1, overflowed=3Dfalse) at ../../gcc/tree.cc:1570 #7 0x0000000000f13238 in fold_convert_const_int_from_int (type=3D, arg1=3D) at ../../gcc/fold-const.cc:2045 #8 0x0000000000f151ec in fold_convert_const (code=3DNOP_EXPR, type=3D, arg1=3D) at ../../gcc/fold-const.cc:2329 #9 0x0000000000f12418 in const_unop (code=3DNOP_EXPR, type=3D, arg0=3D) at ../../gcc/fold-const.cc:1786 #10 0x0000000000f32cc1 in fold_unary_loc (loc=3D0, code=3DNOP_EXPR, type=3D, op0=3D) at ../../gcc/fold-const.cc:9322 #11 0x0000000000f482f6 in fold_build1_loc (loc=3D0, code=3DNOP_EXPR, type=3D, op0=3D) at ../../gcc/fold-const.cc:13767 #12 0x0000000000dad298 in convert_to_integer_1 (type=3D, expr=3D, dofold=3Dtrue) at ../../gcc/convert.cc:688 #13 0x0000000000dae8d9 in convert_to_integer (type=3D, expr=3D) at ../../gcc/convert.= cc:964 #14 0x0000000000b91f78 in convert_loc (location=3D2147483650, type=3D, expr=3D) at ../../gcc/m2/gm2-lang.cc:735 #15 0x0000000000bba6e3 in convert_and_check (loc=3D2147483650, type=3D, expr=3D) at ../../gcc/m2/gm2-gcc/m2convert.cc:316 #16 0x0000000000bbae25 in m2convert_BuildConvert (location=3D2147483650, type=3D, value=3D, checkOverflow=3D1) at ../../gcc/m2/gm2-gcc/m2convert.cc:479 #17 0x0000000000bfde58 in TryDeclareConst (tokenno=3D1975, sym=3D1003) at m2/gm2-compiler-boot/M2GCCDeclare.c:6875 #18 0x0000000000c0613f in M2GCCDeclare_TryDeclareConstant (tokenno=3D1975, sym=3D1003) at m2/gm2-compiler-boot/M2GCCDeclare.c:11574 #19 0x0000000000c3ae9c in FoldAssignment (tokenno=3D1172, q=3D56, r=3D17) at m2/gm2-compiler-boot/M2Range.c:1603 #20 0x0000000000c40bbb in M2Range_FoldRangeCheck (tokenno=3D1172, q=3D56, r= =3D17) at m2/gm2-compiler-boot/M2Range.c:4352 #21 0x0000000000c0774c in FoldRange (tokenno=3D1172, quad=3D56, rangeno=3D1= 7) at m2/gm2-compiler-boot/M2GenGCC.c:2225 #22 0x0000000000c1555d in M2GenGCC_ResolveConstantExpressions (p=3D..., sta= rt=3D53, end=3D61) at m2/gm2-compiler-boot/M2GenGCC.c:8633 #23 0x0000000000bff0b2 in DeclareTypesConstantsProceduresInRange (start=3D5= 3, end=3D61) at m2/gm2-compiler-boot/M2GCCDeclare.c:7548 #24 0x0000000000c44347 in M2Scope_ForeachScopeBlockDo (sb=3D0x3fd37b0, p=3D= ...) at m2/gm2-compiler-boot/M2Scope.c:660 #25 0x0000000000bff254 in DeclareTypesConstantsProcedures (scope=3D155) at m2/gm2-compiler-boot/M2GCCDeclare.c:7631 #26 0x0000000000bff451 in StartDeclareModuleScopeSeparate (scope=3D155) at m2/gm2-compiler-boot/M2GCCDeclare.c:7721 #27 0x0000000000bff65a in StartDeclareModuleScope (scope=3D155) at m2/gm2-compiler-boot/M2GCCDeclare.c:7799 #28 0x0000000000c05e30 in M2GCCDeclare_StartDeclareScope (scope=3D155) at m2/gm2-compiler-boot/M2GCCDeclare.c:11442 #29 0x0000000000bf70dd in DoModuleDeclare () at m2/gm2-compiler-boot/M2Code.c:256 #30 0x0000000000bf7605 in M2Code_Code () at m2/gm2-compiler-boot/M2Code.c:4= 70 #31 0x0000000000bf7a00 in Compile (s=3D0x3f20230) at m2/gm2-compiler-boot/M2Comp.c:211 #32 0x0000000000bf86a1 in M2Comp_compile (filename=3D0x7fffffffe1b6) at m2/gm2-compiler-boot/M2Comp.c:760 converts it into signed 64-bit type and so it becomes -9223372036854775808 and later on FoldAssignment decides it is out of range= and reports: 1608 /* avoid gcc warning by using compound statement even if = not strictly necessary. */ 1609 if (OutOfRange (tokenno, min, p->expr, max, p->desLowestType)) 1610 { 1611 M2MetaError_MetaErrorT2 (p->tokenNo, (const char *) "attempting to assign a value {%2Wa} to a designator {%1a} which will exceed the range of type {%1tad}", 101, p->des, p->expr); 1612 M2Quads_PutQuad (q, M2Quads_ErrorOp, SymbolTable_NulS= ym, SymbolTable_NulSym, r); 1613 }=