public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/105532] New: UBSAN: gcc/hwint.h:293:61: runtime error: shift exponent 64 is too large for 64-bit type 'long unsigned int'
@ 2022-05-09 10:54 zsojka at seznam dot cz
  2022-11-02  1:42 ` [Bug tree-optimization/105532] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: zsojka at seznam dot cz @ 2022-05-09 10:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105532
           Summary: UBSAN: gcc/hwint.h:293:61: runtime error: shift
                    exponent 64 is too large for 64-bit type 'long
                    unsigned int'
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu

Created attachment 52942
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52942&action=edit
reduced testcase

Compiler output:
$ x86_64-pc-linux-gnu-gcc -O testcase.c -c
testcase.c: In function 'foo':
testcase.c:7:15: warning: right shift count >= width of vector element
[-Wshift-count-overflow]
    7 |   return (~(u >> 255));
      |               ^~
/repo/gcc-trunk/gcc/hwint.h:293:61: runtime error: shift exponent 64 is too
large for 64-bit type 'long unsigned int'
/repo/gcc-trunk/gcc/hwint.h:293:72: runtime error: shift exponent 64 is too
large for 64-bit type 'long int'


(gdb) bt
#0  __ubsan::Diag::~Diag (this=this@entry=0x7fffffffbf80, __in_chrg=<optimized
out>) at /repo/gcc-trunk/libsanitizer/ubsan/ubsan_diag.cpp:343
#1  0x00000000074e3aa5 in handleShiftOutOfBoundsImpl
(Data=Data@entry=0x86de5c0, LHS=LHS@entry=18446744073709551615,
RHS=RHS@entry=64, Opts=...) at
/repo/gcc-trunk/libsanitizer/ubsan/ubsan_handlers.cpp:353
#2  0x00000000074e49bf in __ubsan::__ubsan_handle_shift_out_of_bounds
(Data=Data@entry=0x86de5c0, LHS=LHS@entry=18446744073709551615,
RHS=RHS@entry=64)
    at /repo/gcc-trunk/libsanitizer/ubsan/ubsan_handlers.cpp:370
#3  0x00000000006b796e in sext_hwi (prec=<optimized out>, src=<optimized out>)
at /repo/gcc-trunk/gcc/hwint.h:293
#4  wi::hwi_with_prec::hwi_with_prec (s=<optimized out>, p=<optimized out>,
v=<optimized out>, this=<optimized out>) at /repo/gcc-trunk/gcc/wide-int.h:1604
#5  wi::shwi (precision=<optimized out>, val=<optimized out>) at
/repo/gcc-trunk/gcc/wide-int.h:1613
#6  tree_nonzero_bits (t=t@entry=0x7ffff78334f8) at
/repo/gcc-trunk/gcc/fold-const.cc:16607
#7  0x000000000426322f in gimple_simplify_BIT_NOT_EXPR (res_op=0x7fffffffc550,
seq=0x0, valueize=0x2bbee60 <valueize_op_1(tree)>, type=0x7ffff784a000,
_p0=0x7ffff76f3d80, code=...) at gimple-match.cc:67410
#8  0x0000000003e599eb in gimple_simplify (res_op=res_op@entry=0x7fffffffc550,
seq=seq@entry=0x0, valueize=valueize@entry=0x2bbee60 <valueize_op_1(tree)>,
code=..., type=0x7ffff784a000, _p0=0x7ffff76f3d80)
    at gimple-match.cc:90609
#9  0x0000000003e5e779 in gimple_resimplify1 (seq=0x0, res_op=0x7fffffffc740,
valueize=0x2bbee60 <valueize_op_1(tree)>) at
/repo/gcc-trunk/gcc/gimple-match-head.cc:244
#10 0x0000000003f2590c in gimple_simplify (stmt=stmt@entry=0x7ffff7838410,
res_op=<optimized out>, res_op@entry=0x7fffffffc740, seq=<optimized out>,
seq@entry=0x0, valueize=<optimized out>, 
    valueize@entry=0x2bbee60 <valueize_op_1(tree)>, top_valueize=<optimized
out>, top_valueize@entry=0x2bbf480 <valueize_op(tree)>) at
/repo/gcc-trunk/gcc/gimple-match-head.cc:1113
#11 0x00000000016258c0 in gimple_fold_stmt_to_constant_1
(stmt=stmt@entry=0x7ffff7838410, valueize=valueize@entry=0x2bbf480
<valueize_op(tree)>, gvalueize=gvalueize@entry=0x2bbee60 <valueize_op_1(tree)>)
    at /repo/gcc-trunk/gcc/gimple-fold.cc:7391
#12 0x0000000002bd7a52 in ccp_fold (stmt=0x7ffff7838410) at
/repo/gcc-trunk/gcc/tree-ssa-ccp.cc:1289
#13 evaluate_stmt (stmt=0x7ffff7838410) at
/repo/gcc-trunk/gcc/tree-ssa-ccp.cc:2208
#14 0x0000000002bdbfad in visit_assignment (stmt=0x7ffff7838410,
output_p=0x7fffffffcd58) at /repo/gcc-trunk/gcc/tree-ssa-ccp.cc:2841
#15 0x0000000002edd1dc in ssa_propagation_engine::simulate_stmt
(this=this@entry=0x7fffffffcf88, stmt=stmt@entry=0x7ffff7838410) at
/repo/gcc-trunk/gcc/tree-ssa-propagate.cc:230
#16 0x0000000002ede165 in ssa_propagation_engine::simulate_block
(this=0x7fffffffcf88, block=0x7ffff76f4270) at
/repo/gcc-trunk/gcc/tree-ssa-propagate.cc:337
#17 0x0000000002edf73e in ssa_propagation_engine::ssa_propagate
(this=this@entry=0x7fffffffcf88) at
/repo/gcc-trunk/gcc/tree-ssa-propagate.cc:504
#18 0x0000000002bbeccd in do_ssa_ccp (nonzero_p=false) at
/repo/gcc-trunk/gcc/tree-ssa-ccp.cc:2960
#19 (anonymous namespace)::pass_ccp::execute (this=<optimized out>) at
/repo/gcc-trunk/gcc/tree-ssa-ccp.cc:3004
#20 0x00000000021af318 in execute_one_pass (pass=0xc66bc70) at
/repo/gcc-trunk/gcc/passes.cc:2638
#21 0x00000000021b2902 in execute_pass_list_1 (pass=0xc66bc70) at
/repo/gcc-trunk/gcc/passes.cc:2738
#22 0x00000000021b2945 in execute_pass_list_1 (pass=0xc66bb50) at
/repo/gcc-trunk/gcc/passes.cc:2739
#23 0x00000000021b29f9 in execute_pass_list (fn=0x7ffff784c000, pass=<optimized
out>) at /repo/gcc-trunk/gcc/passes.cc:2749
#24 0x00000000021a1bc2 in do_per_function_toporder (callback=0x21b29e0
<execute_pass_list(function*, opt_pass*)>, data=0xc66b950) at
/repo/gcc-trunk/gcc/passes.cc:1774
#25 0x00000000021b3d7a in do_per_function_toporder (data=<optimized out>,
callback=0x21b29e0 <execute_pass_list(function*, opt_pass*)>) at
/repo/gcc-trunk/gcc/plugin.h:191
#26 execute_ipa_pass_list (pass=0xc66b8f0) at
/repo/gcc-trunk/gcc/passes.cc:3083
#27 0x0000000000f92b54 in ipa_passes () at
/repo/gcc-trunk/gcc/cgraphunit.cc:2161
#28 symbol_table::compile (this=0x7ffff76ec000) at
/repo/gcc-trunk/gcc/cgraphunit.cc:2282
#29 0x0000000000fa02ad in symbol_table::compile (this=0x7ffff76ec000) at
/repo/gcc-trunk/gcc/cgraphunit.cc:2262
#30 symbol_table::finalize_compilation_unit (this=0x7ffff76ec000) at
/repo/gcc-trunk/gcc/cgraphunit.cc:2530
#31 0x00000000026d34a3 in compile_file () at /repo/gcc-trunk/gcc/toplev.cc:479
#32 0x0000000000917d45 in do_compile (no_backend=false) at
/repo/gcc-trunk/gcc/toplev.cc:2168
#33 toplev::main (this=this@entry=0x7fffffffd35e, argc=<optimized out>,
argc@entry=15, argv=<optimized out>, argv@entry=0x7fffffffd4a8) at
/repo/gcc-trunk/gcc/toplev.cc:2320
#34 0x000000000091bb6b in main (argc=15, argv=0x7fffffffd4a8) at
/repo/gcc-trunk/gcc/main.cc:39

$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r13-167-20220507103325-g0c723bb4be2-checking-release-bootstrap-ubsan-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/13.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=release
--with-build-config=bootstrap-ubsan --with-cloog --with-ppl --with-isl
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
--target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r13-167-20220507103325-g0c723bb4be2-checking-release-bootstrap-ubsan-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.0.0 20220507 (experimental) (GCC)

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-05-29 10:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-09 10:54 [Bug tree-optimization/105532] New: UBSAN: gcc/hwint.h:293:61: runtime error: shift exponent 64 is too large for 64-bit type 'long unsigned int' zsojka at seznam dot cz
2022-11-02  1:42 ` [Bug tree-optimization/105532] " pinskia at gcc dot gnu.org
2022-11-02  1:51 ` [Bug tree-optimization/105532] [11/12/13 Regression] " pinskia at gcc dot gnu.org
2022-11-02  6:36 ` pinskia at gcc dot gnu.org
2022-11-02 16:24 ` pinskia at gcc dot gnu.org
2022-11-02 16:30 ` pinskia at gcc dot gnu.org
2022-11-02 21:47 ` pinskia at gcc dot gnu.org
2022-12-20 13:45 ` rguenth at gcc dot gnu.org
2022-12-21 18:33 ` cvs-commit at gcc dot gnu.org
2022-12-21 18:34 ` [Bug tree-optimization/105532] [11/12 " pinskia at gcc dot gnu.org
2023-03-11  1:29 ` cvs-commit at gcc dot gnu.org
2023-03-11  1:30 ` [Bug tree-optimization/105532] [11 " pinskia at gcc dot gnu.org
2023-05-29 10:06 ` jakub at gcc dot gnu.org

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).