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

            Bug ID: 121326
           Summary: UBSAN error in use_related_value (signed integer
                    overflow: 4707129865599665876 - -7070675565921424023
                    cannot be represented in type 'long int')
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
            Blocks: 63426
  Target Milestone: ---

```
$ export
UBSAN_OPTIONS="halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1"
$ g++ -c ./obj/net/third_party/quiche/quiche/spdy_utils.ii -std=gnu++20 -O3
-march=znver3 -mshstk -fPIC
/var/tmp/portage/sys-devel/gcc-16.0.9999/work/gcc-16.0.9999/gcc/cse.cc:2190:34:
runtime error: signed integer overflow: 4707129865599665876 -
-7070675565921424023 cannot be represented in type 'long int'
    #0 0x55aff7584c23 in use_related_value
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cse.cc:2190
    #1 0x55aff7598cc5 in cse_insn
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cse.cc:4860
    #2 0x55aff75b3484 in cse_extended_basic_block
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cse.cc:6583
    #3 0x55aff75b3484 in cse_main
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cse.cc:6736
    #4 0x55aff75b9361 in rest_of_handle_cse_after_global_opts
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cse.cc:7725
    #5 0x55aff75b9361 in execute
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cse.cc:7776
    #6 0x55aff21d2f30 in execute_one_pass(opt_pass*)
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/passes.cc:2648
    #7 0x55aff21d5db0 in execute_pass_list_1
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/passes.cc:2757
    #8 0x55aff21d5df7 in execute_pass_list_1
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/passes.cc:2758
    #9 0x55aff21d5ebc in execute_pass_list(function*, opt_pass*)
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/passes.cc:2768
    #10 0x55aff0df1a8e in cgraph_node::expand()
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cgraphunit.cc:1859
    #11 0x55aff0df1a8e in cgraph_node::expand()
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cgraphunit.cc:1812
    #12 0x55aff0e037ed in expand_all_functions
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cgraphunit.cc:2042
    #13 0x55aff0e037ed in symbol_table::compile()
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cgraphunit.cc:2419
    #14 0x55aff0e045b0 in symbol_table::compile()
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cgraphunit.cc:2329
    #15 0x55aff0e045b0 in symbol_table::finalize_compilation_unit()
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cgraphunit.cc:2608
    #16 0x55aff2836690 in compile_file
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/toplev.cc:480
    #17 0x55afefbf9814 in do_compile
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/toplev.cc:2220
    #18 0x55afefbf9814 in toplev::main(int, char**)
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/toplev.cc:2383
    #19 0x55afefbfd024 in main
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/main.cc:39
    #20 0x7fd6c8a277ca  (/usr/lib64/libc.so.6+0x277ca)
    #21 0x7fd6c8a27879 in __libc_start_main (/usr/lib64/libc.so.6+0x27879)
    #22 0x55afefbfd524 in _start
(/usr/libexec/gcc/x86_64-pc-linux-gnu/16/cc1plus+0x7b67524)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
/var/tmp/portage/sys-devel/gcc-16.0.9999/work/gcc-16.0.9999/gcc/cse.cc:2190:34 
during RTL pass: cse_local
../../../../../qtwebengine-everywhere-src-6.9.1/src/3rdparty/chromium/net/third_party/quiche/src/quiche/quic/core/http/spdy_utils.cc:
In static member function ‘static bool
quic::SpdyUtils::ExtractContentLengthFromHeaders(int64_t*,
quiche::HttpHeaderBlock*)’:
../../../../../qtwebengine-everywhere-src-6.9.1/src/3rdparty/chromium/net/third_party/quiche/src/quiche/quic/core/http/spdy_utils.cc:60:1:
internal compiler error: Aborted
   60 | }
      | ^
0x55aff817d9ef internal_error(char const*, ...)
       
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/diagnostic-global-context.cc:534
0x55aff28342d7 crash_signal
        /usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/toplev.cc:323
0x55afefbf5c2e __sanitizer::Abort()
       
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp:163
0x55aff8645e6b __sanitizer::Die()
       
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/libsanitizer/sanitizer_common/sanitizer_termination.cpp:58
0x55aff8646ab6 __ubsan::ScopedReport::~ScopedReport()
       
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/libsanitizer/ubsan/ubsan_diag.cpp:402
0x55aff863ba0e handleIntegerOverflowImpl<__ubsan::Value>
       
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/libsanitizer/ubsan/ubsan_handlers.cpp:231
0x55aff863f8dc __ubsan_handle_sub_overflow
       
/usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/libsanitizer/ubsan/ubsan_handlers.cpp:244
0x55aff7584c23 use_related_value
        /usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cse.cc:2190
0x55aff7598cc5 cse_insn
        /usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cse.cc:4860
0x55aff75b3484 cse_extended_basic_block
        /usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cse.cc:6583
0x55aff75b3484 cse_main
        /usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cse.cc:6736
0x55aff75b9361 rest_of_handle_cse_after_global_opts
        /usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cse.cc:7725
0x55aff75b9361 execute
        /usr/src/debug/sys-devel/gcc-16.0.9999/gcc-16.0.9999/gcc/cse.cc:7776
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.
```

```
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/16/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-16.0.9999/work/gcc-16.0.9999/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/16
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/16/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/16
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/16/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/16/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/16/include/g++-v16
--disable-silent-rules --disable-dependency-tracking
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/16/python
--enable-libphobos --enable-objc-gc
--enable-languages=c,c++,d,objc,obj-c++,fortran,ada,rust --enable-obsolete
--enable-secureplt --disable-werror --with-system-zlib --enable-nls
--without-included-gettext --disable-libunwind-exceptions
--enable-checking=release --with-bugurl=https://bugs.gentoo.org/
--with-pkgversion='Gentoo 16.0.9999 p, commit
8cda62318174b911a7cba57fcf70efd38f265f0e' --with-gcc-major-version-only
--enable-libstdcxx-time --enable-lto --disable-libstdcxx-pch --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
--enable-multilib --with-multilib-list=m32,m64 --disable-fixed-point
--enable-targets=all --enable-offload-defaulted
--enable-offload-targets=nvptx-none --enable-libgomp --disable-libssp
--enable-libada --enable-cet --disable-systemtap --enable-valgrind-annotations
--disable-vtable-verify --disable-libvtv --with-zstd --without-isl
--enable-default-pie --enable-host-pie --enable-host-bind-now
--enable-default-ssp --disable-fixincludes
--with-gxx-libcxx-include-dir=/usr/include/c++/v1
--with-build-config='bootstrap-ubsan bootstrap-cet'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.0.0 20250730 (experimental)
7aa9565a62ea2ce04e2ddf61e1932bc123374988 (Gentoo 16.0.9999 p, commit
8cda62318174b911a7cba57fcf70efd38f265f0e)
```


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63426
[Bug 63426] [meta-bug] Issues found with -fsanitize=undefined

Reply via email to