From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2E08738425B2; Mon, 9 May 2022 10:54:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E08738425B2 From: "zsojka at seznam dot cz" To: gcc-bugs@gcc.gnu.org Subject: [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' Date: Mon, 09 May 2022 10:54:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: zsojka at seznam dot cz X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone cf_gcchost attachments.created Message-ID: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 May 2022 10:54:24 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105532 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=3D52942&action=3Dedit 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 >=3D 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=3Dthis@entry=3D0x7fffffffbf80, __in_chrg=3D<= optimized out>) at /repo/gcc-trunk/libsanitizer/ubsan/ubsan_diag.cpp:343 #1 0x00000000074e3aa5 in handleShiftOutOfBoundsImpl (Data=3DData@entry=3D0x86de5c0, LHS=3DLHS@entry=3D18446744073709551615, RHS=3DRHS@entry=3D64, Opts=3D...) at /repo/gcc-trunk/libsanitizer/ubsan/ubsan_handlers.cpp:353 #2 0x00000000074e49bf in __ubsan::__ubsan_handle_shift_out_of_bounds (Data=3DData@entry=3D0x86de5c0, LHS=3DLHS@entry=3D18446744073709551615, RHS=3DRHS@entry=3D64) at /repo/gcc-trunk/libsanitizer/ubsan/ubsan_handlers.cpp:370 #3 0x00000000006b796e in sext_hwi (prec=3D, src=3D) at /repo/gcc-trunk/gcc/hwint.h:293 #4 wi::hwi_with_prec::hwi_with_prec (s=3D, p=3D, v=3D, this=3D) at /repo/gcc-trunk/gcc/wide-in= t.h:1604 #5 wi::shwi (precision=3D, val=3D) at /repo/gcc-trunk/gcc/wide-int.h:1613 #6 tree_nonzero_bits (t=3Dt@entry=3D0x7ffff78334f8) at /repo/gcc-trunk/gcc/fold-const.cc:16607 #7 0x000000000426322f in gimple_simplify_BIT_NOT_EXPR (res_op=3D0x7fffffff= c550, seq=3D0x0, valueize=3D0x2bbee60 , type=3D0x7ffff784a00= 0, _p0=3D0x7ffff76f3d80, code=3D...) at gimple-match.cc:67410 #8 0x0000000003e599eb in gimple_simplify (res_op=3Dres_op@entry=3D0x7fffff= ffc550, seq=3Dseq@entry=3D0x0, valueize=3Dvalueize@entry=3D0x2bbee60 , code=3D..., type=3D0x7ffff784a000, _p0=3D0x7ffff76f3d80) at gimple-match.cc:90609 #9 0x0000000003e5e779 in gimple_resimplify1 (seq=3D0x0, res_op=3D0x7ffffff= fc740, valueize=3D0x2bbee60 ) at /repo/gcc-trunk/gcc/gimple-match-head.cc:244 #10 0x0000000003f2590c in gimple_simplify (stmt=3Dstmt@entry=3D0x7ffff78384= 10, res_op=3D, res_op@entry=3D0x7fffffffc740, seq=3D, seq@entry=3D0x0, valueize=3D,=20 valueize@entry=3D0x2bbee60 , top_valueize=3D, top_valueize@entry=3D0x2bbf480 ) at /repo/gcc-trunk/gcc/gimple-match-head.cc:1113 #11 0x00000000016258c0 in gimple_fold_stmt_to_constant_1 (stmt=3Dstmt@entry=3D0x7ffff7838410, valueize=3Dvalueize@entry=3D0x2bbf480 , gvalueize=3Dgvalueize@entry=3D0x2bbee60 ) at /repo/gcc-trunk/gcc/gimple-fold.cc:7391 #12 0x0000000002bd7a52 in ccp_fold (stmt=3D0x7ffff7838410) at /repo/gcc-trunk/gcc/tree-ssa-ccp.cc:1289 #13 evaluate_stmt (stmt=3D0x7ffff7838410) at /repo/gcc-trunk/gcc/tree-ssa-ccp.cc:2208 #14 0x0000000002bdbfad in visit_assignment (stmt=3D0x7ffff7838410, output_p=3D0x7fffffffcd58) at /repo/gcc-trunk/gcc/tree-ssa-ccp.cc:2841 #15 0x0000000002edd1dc in ssa_propagation_engine::simulate_stmt (this=3Dthis@entry=3D0x7fffffffcf88, stmt=3Dstmt@entry=3D0x7ffff7838410) at /repo/gcc-trunk/gcc/tree-ssa-propagate.cc:230 #16 0x0000000002ede165 in ssa_propagation_engine::simulate_block (this=3D0x7fffffffcf88, block=3D0x7ffff76f4270) at /repo/gcc-trunk/gcc/tree-ssa-propagate.cc:337 #17 0x0000000002edf73e in ssa_propagation_engine::ssa_propagate (this=3Dthis@entry=3D0x7fffffffcf88) at /repo/gcc-trunk/gcc/tree-ssa-propagate.cc:504 #18 0x0000000002bbeccd in do_ssa_ccp (nonzero_p=3Dfalse) at /repo/gcc-trunk/gcc/tree-ssa-ccp.cc:2960 #19 (anonymous namespace)::pass_ccp::execute (this=3D) at /repo/gcc-trunk/gcc/tree-ssa-ccp.cc:3004 #20 0x00000000021af318 in execute_one_pass (pass=3D0xc66bc70) at /repo/gcc-trunk/gcc/passes.cc:2638 #21 0x00000000021b2902 in execute_pass_list_1 (pass=3D0xc66bc70) at /repo/gcc-trunk/gcc/passes.cc:2738 #22 0x00000000021b2945 in execute_pass_list_1 (pass=3D0xc66bb50) at /repo/gcc-trunk/gcc/passes.cc:2739 #23 0x00000000021b29f9 in execute_pass_list (fn=3D0x7ffff784c000, pass=3D) at /repo/gcc-trunk/gcc/passes.cc:2749 #24 0x00000000021a1bc2 in do_per_function_toporder (callback=3D0x21b29e0 , data=3D0xc66b950) at /repo/gcc-trunk/gcc/passes.cc:1774 #25 0x00000000021b3d7a in do_per_function_toporder (data=3D, callback=3D0x21b29e0 ) at /repo/gcc-trunk/gcc/plugin.h:191 #26 execute_ipa_pass_list (pass=3D0xc66b8f0) 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=3D0x7ffff76ec000) at /repo/gcc-trunk/gcc/cgraphunit.cc:2282 #29 0x0000000000fa02ad in symbol_table::compile (this=3D0x7ffff76ec000) at /repo/gcc-trunk/gcc/cgraphunit.cc:2262 #30 symbol_table::finalize_compilation_unit (this=3D0x7ffff76ec000) 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=3Dfalse) at /repo/gcc-trunk/gcc/toplev.cc:2168 #33 toplev::main (this=3Dthis@entry=3D0x7fffffffd35e, argc=3D, argc@entry=3D15, argv=3D, argv@entry=3D0x7fffffffd4a8) at /repo/gcc-trunk/gcc/toplev.cc:2320 #34 0x000000000091bb6b in main (argc=3D15, argv=3D0x7fffffffd4a8) at /repo/gcc-trunk/gcc/main.cc:39 $ x86_64-pc-linux-gnu-gcc -v Using built-in specs. COLLECT_GCC=3D/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-g= cc COLLECT_LTO_WRAPPER=3D/repo/gcc-trunk/binary-trunk-r13-167-20220507103325-g= 0c723bb4be2-checking-release-bootstrap-ubsan-amd64/bin/../libexec/gcc/x86_6= 4-pc-linux-gnu/13.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /repo/gcc-trunk//configure --enable-languages=3Dc,c++ --enable-valgrind-annotations --disable-nls --enable-checking=3Drelease --with-build-config=3Dbootstrap-ubsan --with-cloog --with-ppl --with-isl --build=3Dx86_64-pc-linux-gnu --host=3Dx86_64-pc-linux-gnu --target=3Dx86_64-pc-linux-gnu --with-ld=3D/usr/bin/x86_64-pc-linux-gnu-ld --with-as=3D/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch --prefix=3D/repo/gcc-trunk//binary-trunk-r13-167-20220507103325-g0c723bb4be= 2-checking-release-bootstrap-ubsan-amd64 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.0.0 20220507 (experimental) (GCC)=