From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9B69538485A4; Mon, 9 May 2022 11:27:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B69538485A4 From: "zsojka at seznam dot cz" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/105533] New: UBSAN: gcc/expmed.cc:3272:26: runtime error: signed integer overflow: -9223372036854775808 - 1 cannot be represented in type 'long int' Date: Mon, 09 May 2022 11:27:56 +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 11:27:56 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105533 Bug ID: 105533 Summary: UBSAN: gcc/expmed.cc:3272:26: runtime error: signed integer overflow: -9223372036854775808 - 1 cannot be represented in type 'long 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 52943 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52943&action=3Dedit reduced testcase Compiler output: $ x86_64-pc-linux-gnu-gcc -O testcase.c -c /repo/gcc-trunk/gcc/expmed.cc:3272:26: runtime error: signed integer overfl= ow: -9223372036854775808 - 1 cannot be represented in type 'long int' (gdb) bt #0 __ubsan::Diag::~Diag (this=3Dthis@entry=3D0x7fffffffc250, __in_chrg=3D<= optimized out>) at /repo/gcc-trunk/libsanitizer/ubsan/ubsan_diag.cpp:343 #1 0x00000000074e14ec in handleIntegerOverflowImpl<__ubsan::Value> (Data=3DData@entry=3D0x85fd8e0, LHS=3DLHS@entry=3D9223372036854775808, Operator=3DOperator@entry=3D0x7b7c28d "-", RHS=3D..., Opts=3D...) at /repo/gcc-trunk/libsanitizer/ubsan/ubsan_handlers.cpp:227 #2 0x00000000074e478d in __ubsan::__ubsan_handle_sub_overflow (Data=3DData@entry=3D0x85fd8e0, LHS=3DLHS@entry=3D9223372036854775808, RHS= =3DRHS@entry=3D1) at /repo/gcc-trunk/libsanitizer/ubsan/ubsan_handlers.cpp:244 #3 0x0000000001384d5d in choose_mult_variant (mode=3DE_DImode, val=3D, alg=3D0x7fffffffc6b0, variant=3D0x7fffffffc6ac, mult_cost=3D16) at /repo/gcc-trunk/gcc/expmed.cc:3272 #4 0x0000000001385946 in mult_by_coeff_cost (coeff=3D-9223372036854775808, mode=3DE_DImode, speed=3D) at /repo/gcc-trunk/gcc/expmed.cc:= 3610 #5 0x00000000068ae3ac in create_add_ssa_cand (gs=3D0x7ffff7851a50, base_in=3D0x7ffff7852ea0, addend_in=3D, subtract_p=3Dfalse, speed=3Dtrue) at /repo/gcc-trunk/gcc/gimple-ssa-strength-reduction.cc:1311 #6 0x00000000068b4668 in slsr_process_add (speed=3Dtrue, rhs2=3D0x7ffff785= 2ea0, rhs1=3D, gs=3D) at /repo/gcc-trunk/gcc/gimple-ssa-strength-reduction.cc:1484 #7 find_candidates_dom_walker::before_dom_children (this=3D, bb=3D) at /repo/gcc-trunk/gcc/gimple-ssa-strength-reduction.cc:1803 #8 0x000000000665b9e5 in dom_walker::walk (this=3D, bb=3D0x7ffff76f4478) at /repo/gcc-trunk/gcc/domwalk.cc:309 #9 0x000000000689d07a in (anonymous namespace)::pass_strength_reduction::execute (this=3D, fun=3D0x7ffff784c0b8) at /repo/gcc-trunk/gcc/gimple-ssa-strength-reduction.cc:4039 #10 0x00000000021af318 in execute_one_pass (pass=3D0xc6701b0) at /repo/gcc-trunk/gcc/passes.cc:2638 #11 0x00000000021b2902 in execute_pass_list_1 (pass=3D0xc6701b0) at /repo/gcc-trunk/gcc/passes.cc:2738 #12 0x00000000021b2945 in execute_pass_list_1 (pass=3D0xc66dcc0) at /repo/gcc-trunk/gcc/passes.cc:2739 #13 0x00000000021b29f9 in execute_pass_list (fn=3D0x7ffff784c0b8, pass=3D) at /repo/gcc-trunk/gcc/passes.cc:2749 #14 0x0000000000f8cebc in cgraph_node::expand (this=3D0x7ffff784f110) at /repo/gcc-trunk/gcc/cgraphunit.cc:1835 #15 0x0000000000f92108 in expand_all_functions () at /repo/gcc-trunk/gcc/cgraphunit.cc:1999 #16 symbol_table::compile (this=3D0x7ffff76ec000) at /repo/gcc-trunk/gcc/cgraphunit.cc:2349 #17 0x0000000000fa02ad in symbol_table::compile (this=3D0x7ffff76ec000) at /repo/gcc-trunk/gcc/cgraphunit.cc:2262 #18 symbol_table::finalize_compilation_unit (this=3D0x7ffff76ec000) at /repo/gcc-trunk/gcc/cgraphunit.cc:2530 #19 0x00000000026d34a3 in compile_file () at /repo/gcc-trunk/gcc/toplev.cc:= 479 #20 0x0000000000917d45 in do_compile (no_backend=3Dfalse) at /repo/gcc-trunk/gcc/toplev.cc:2168 #21 toplev::main (this=3Dthis@entry=3D0x7fffffffd27e, argc=3D, argc@entry=3D17, argv=3D, argv@entry=3D0x7fffffffd3c8) at /repo/gcc-trunk/gcc/toplev.cc:2320 #22 0x000000000091bb6b in main (argc=3D17, argv=3D0x7fffffffd3c8) 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)=