public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-108121-4-qWss8StC6t@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108121-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108121

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #2)
> > gm2.log: FAIL: gm2/pim/pass/TestLong4.mod,  -g  
> 
> And this one fails due to UBSAN (signed integer overflow):
> 
> /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 represented
> 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 with
performing the
  test_high = res_high + add_high;
addition in append_m2_digit in unsigned and test_high = res_high + add_high; in
append_digit in unsigned HOST_WIDE_INT type, like:
  test_high = (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 fits.
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 x86_64
seems to be unsigned 64-bit type, so 9223372036854775808 constant certainly
fits there, but then:
#4  0x0000000001856de7 in make_int_cst (len=1, ext_len=1) at
../../gcc/tree.cc:2727
#5  0x000000000185268e in build_new_int_cst (type=<integer_type
0x7fffea15a540>, cst=...) at ../../gcc/tree.cc:1456
#6  0x0000000001852c9a in force_fit_type (type=<integer_type 0x7fffea15a540>,
cst=..., overflowable=1, overflowed=false) at ../../gcc/tree.cc:1570
#7  0x0000000000f13238 in fold_convert_const_int_from_int (type=<integer_type
0x7fffea15a540>, arg1=<integer_cst 0x7fffea12d9a0>) at
../../gcc/fold-const.cc:2045
#8  0x0000000000f151ec in fold_convert_const (code=NOP_EXPR, type=<integer_type
0x7fffea15a540>, arg1=<integer_cst 0x7fffea12d9a0>) at
../../gcc/fold-const.cc:2329
#9  0x0000000000f12418 in const_unop (code=NOP_EXPR, type=<integer_type
0x7fffea15a540>, arg0=<integer_cst 0x7fffea12d9a0>) at
../../gcc/fold-const.cc:1786
#10 0x0000000000f32cc1 in fold_unary_loc (loc=0, code=NOP_EXPR,
type=<integer_type 0x7fffea15a540>, op0=<integer_cst 0x7fffea12d9a0>) at
../../gcc/fold-const.cc:9322
#11 0x0000000000f482f6 in fold_build1_loc (loc=0, code=NOP_EXPR,
type=<integer_type 0x7fffea15a540>, op0=<integer_cst 0x7fffea12d9a0>) at
../../gcc/fold-const.cc:13767
#12 0x0000000000dad298 in convert_to_integer_1 (type=<integer_type
0x7fffea15a540>, expr=<integer_cst 0x7fffea12d9a0>, dofold=true) at
../../gcc/convert.cc:688
#13 0x0000000000dae8d9 in convert_to_integer (type=<integer_type
0x7fffea15a540>, expr=<integer_cst 0x7fffea12d9a0>) at ../../gcc/convert.cc:964
#14 0x0000000000b91f78 in convert_loc (location=2147483650, type=<integer_type
0x7fffea15a540>, expr=<integer_cst 0x7fffea12d9a0>) at
../../gcc/m2/gm2-lang.cc:735
#15 0x0000000000bba6e3 in convert_and_check (loc=2147483650, type=<integer_type
0x7fffea15a540>, expr=<integer_cst 0x7fffea12d9a0>) at
../../gcc/m2/gm2-gcc/m2convert.cc:316
#16 0x0000000000bbae25 in m2convert_BuildConvert (location=2147483650,
type=<integer_type 0x7fffea15a540>, value=<integer_cst 0x7fffea12d9a0>,
checkOverflow=1)
    at ../../gcc/m2/gm2-gcc/m2convert.cc:479
#17 0x0000000000bfde58 in TryDeclareConst (tokenno=1975, sym=1003) at
m2/gm2-compiler-boot/M2GCCDeclare.c:6875
#18 0x0000000000c0613f in M2GCCDeclare_TryDeclareConstant (tokenno=1975,
sym=1003) at m2/gm2-compiler-boot/M2GCCDeclare.c:11574
#19 0x0000000000c3ae9c in FoldAssignment (tokenno=1172, q=56, r=17) at
m2/gm2-compiler-boot/M2Range.c:1603
#20 0x0000000000c40bbb in M2Range_FoldRangeCheck (tokenno=1172, q=56, r=17) at
m2/gm2-compiler-boot/M2Range.c:4352
#21 0x0000000000c0774c in FoldRange (tokenno=1172, quad=56, rangeno=17) at
m2/gm2-compiler-boot/M2GenGCC.c:2225
#22 0x0000000000c1555d in M2GenGCC_ResolveConstantExpressions (p=..., start=53,
end=61) at m2/gm2-compiler-boot/M2GenGCC.c:8633
#23 0x0000000000bff0b2 in DeclareTypesConstantsProceduresInRange (start=53,
end=61) at m2/gm2-compiler-boot/M2GCCDeclare.c:7548
#24 0x0000000000c44347 in M2Scope_ForeachScopeBlockDo (sb=0x3fd37b0, p=...) at
m2/gm2-compiler-boot/M2Scope.c:660
#25 0x0000000000bff254 in DeclareTypesConstantsProcedures (scope=155) at
m2/gm2-compiler-boot/M2GCCDeclare.c:7631
#26 0x0000000000bff451 in StartDeclareModuleScopeSeparate (scope=155) at
m2/gm2-compiler-boot/M2GCCDeclare.c:7721
#27 0x0000000000bff65a in StartDeclareModuleScope (scope=155) at
m2/gm2-compiler-boot/M2GCCDeclare.c:7799
#28 0x0000000000c05e30 in M2GCCDeclare_StartDeclareScope (scope=155) 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:470
#31 0x0000000000bf7a00 in Compile (s=0x3f20230) at
m2/gm2-compiler-boot/M2Comp.c:211
#32 0x0000000000bf86a1 in M2Comp_compile (filename=0x7fffffffe1b6) 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_NulSym,
SymbolTable_NulSym, r);
1613                }

  parent reply	other threads:[~2022-12-20 14:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-15  9:13 [Bug modula2/108121] New: " marxin at gcc dot gnu.org
2022-12-15  9:14 ` [Bug modula2/108121] " marxin at gcc dot gnu.org
2022-12-15  9:14 ` marxin at gcc dot gnu.org
2022-12-15  9:23 ` marxin at gcc dot gnu.org
2022-12-20 14:26 ` jakub at gcc dot gnu.org [this message]
2023-01-15 13:22 ` gaius at gcc dot gnu.org
2023-01-15 13:28 ` gaius at gcc dot gnu.org
2023-04-26  0:28 ` gaius at gcc dot gnu.org
2023-04-26  1:24 ` gaius at gcc dot gnu.org
2023-04-26  1:57 ` cvs-commit at gcc dot gnu.org
2023-04-26  6:57 ` rguenth at gcc dot gnu.org
2023-07-27  9:24 ` rguenth at gcc dot gnu.org
2023-07-28  2:10 ` cvs-commit at gcc dot gnu.org
2023-07-28  2:28 ` gaius at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-108121-4-qWss8StC6t@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).