From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 710163858D37; Mon, 15 Aug 2022 13:14:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 710163858D37 From: "gcc.gnu at vvalter dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106627] New: Exception from multiversion function cannot be caught Date: Mon, 15 Aug 2022 13:14:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gcc.gnu at vvalter dot com 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 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, 15 Aug 2022 13:14:53 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106627 Bug ID: 106627 Summary: Exception from multiversion function cannot be caught Product: gcc Version: 12.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gcc.gnu at vvalter dot com Target Milestone: --- An exception thrown by a multiversioned function cannot be caught in the ca= lled function. I expect the following program to exit with status code 0, but it gets terminated because of an uncaught exception. With clang, the program w= orks as expected. According to godbolt.org it's also broken in gcc trunk and all other versions that I checked: https://godbolt.org/z/564c6q8xo __attribute__((target("default"))) void f() { throw 1; } __attribute__((target("sse4.2,bmi"))) void f() { throw 2; } int main() { try { f(); } catch(... ) { return 0; } return 1; } Output of g++ -v: Using built-in specs. COLLECT_GCC=3Dg++ COLLECT_LTO_WRAPPER=3D/usr/libexec/gcc/x86_64-redhat-linux/12/lto-wrapper OFFLOAD_TARGET_NAMES=3Dnvptx-none OFFLOAD_TARGET_DEFAULT=3D1 Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=3Dc,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=3D/usr --mandir=3D/usr/share/man --infodir=3D/usr/share/info --with-bugurl=3Dhttp://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=3Dposix --enable-checking=3Drelease --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-linker-hash-style=3Dgnu --enable-plugin --enable-initfini-array --with-isl=3D/builddir/build/BUILD/gcc-12.1.1-20220507/obj-x86_64-redhat-li= nux/isl-install --enable-offload-targets=3Dnvptx-none --without-cuda-driver --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=3Dgeneric --with-arch_32=3Di686 --build=3Dx86_64-redhat-linux --with-build-config=3Dbootstrap-lto --enable-link-serialization=3D1 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.1.1 20220507 (Red Hat 12.1.1-1) (GCC) COLLECT_GCC_OPTIONS=3D'-v' '-save-temps' '-shared-libgcc' '-mtune=3Dgeneric' '-march=3Dx86-64' '-dumpdir' 'a-' /usr/libexec/gcc/x86_64-redhat-linux/12/cc1plus -E -quiet -v -D_GNU_SOURCE bug.cpp -mtune=3Dgeneric -march=3Dx86-64 -fpch-preprocess -o a-bug.ii ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/12/include-fixed" ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/includ= e" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12 /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/x86_64-redha= t-linux /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/backward /usr/lib/gcc/x86_64-redhat-linux/12/include /usr/local/include /usr/include End of search list. COLLECT_GCC_OPTIONS=3D'-v' '-save-temps' '-shared-libgcc' '-mtune=3Dgeneric' '-march=3Dx86-64' '-dumpdir' 'a-' /usr/libexec/gcc/x86_64-redhat-linux/12/cc1plus -fpreprocessed a-bug.ii -q= uiet -dumpdir a- -dumpbase bug.cpp -dumpbase-ext .cpp -mtune=3Dgeneric -march=3D= x86-64 -version -o a-bug.s GNU C++17 (GCC) version 12.1.1 20220507 (Red Hat 12.1.1-1) (x86_64-redhat-linux) compiled by GNU C version 12.1.1 20220507 (Red Hat 12.1.1-1), GMP version 6.2.1, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=3D100 --param ggc-min-heapsize=3D131= 072 GNU C++17 (GCC) version 12.1.1 20220507 (Red Hat 12.1.1-1) (x86_64-redhat-linux) compiled by GNU C version 12.1.1 20220507 (Red Hat 12.1.1-1), GMP version 6.2.1, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=3D100 --param ggc-min-heapsize=3D131= 072 Compiler executable checksum: 2b1c93ff5f3b69a44b0e1b07f6437558 COLLECT_GCC_OPTIONS=3D'-v' '-save-temps' '-shared-libgcc' '-mtune=3Dgeneric' '-march=3Dx86-64' '-dumpdir' 'a-' as -v --64 -o a-bug.o a-bug.s GNU assembler version 2.37 (x86_64-redhat-linux) using BFD version version 2.37-27.fc36 COMPILER_PATH=3D/usr/libexec/gcc/x86_64-redhat-linux/12/:/usr/libexec/gcc/x= 86_64-redhat-linux/12/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x= 86_64-redhat-linux/12/:/usr/lib/gcc/x86_64-redhat-linux/ LIBRARY_PATH=3D/usr/lib/gcc/x86_64-redhat-linux/12/:/usr/lib/gcc/x86_64-red= hat-linux/12/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/= gcc/x86_64-redhat-linux/12/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS=3D'-v' '-save-temps' '-shared-libgcc' '-mtune=3Dgeneric' '-march=3Dx86-64' '-dumpdir' 'a.' /usr/libexec/gcc/x86_64-redhat-linux/12/collect2 -plugin /usr/libexec/gcc/x86_64-redhat-linux/12/liblto_plugin.so -plugin-opt=3D/usr/libexec/gcc/x86_64-redhat-linux/12/lto-wrapper -plugin-opt=3D-fresolution=3Da.res -plugin-opt=3D-pass-through=3D-lgcc_s -plugin-opt=3D-pass-through=3D-lgcc -plugin-opt=3D-pass-through=3D-lc -plugin-opt=3D-pass-through=3D-lgcc_s -plugin-opt=3D-pass-through=3D-lgcc -= -build-id --no-add-needed --eh-frame-hdr --hash-style=3Dgnu -m elf_x86_64 -dynamic-li= nker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/12/crtbegin.o -L/usr/lib/gcc/x86_64-redhat-linux/12 -L/usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/12/../../.. a-bug.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-redhat-linux/12/crtend.o /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crtn.o COLLECT_GCC_OPTIONS=3D'-v' '-save-temps' '-shared-libgcc' '-mtune=3Dgeneric' '-march=3Dx86-64' '-dumpdir' 'a.'=