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

            Bug ID: 104770
           Summary: std::any_cast cause SIGBUS instead of throwing
                    std::bad_any_cast
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: payload.prom0j at icloud dot com
  Target Milestone: ---

Created attachment 52555
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52555&action=edit
test code

std::any a1="123.456";

    try
    {
      std::cout<<"  std::any_cast<double>(a1) =
"<<std::any_cast<double>(a1)<<std::endl;
    }
    catch(std::exception const &e)
    {
      std::cout<<"  std::any_cast<double>(a1) generate exception:
"<<e.what()<<std::endl;
    }


std::any_cast a char* to double should raise a std::bad_any_cast exception but
a SIGBUS is generated.




gcc details:
victor@Turing test_gcc_any_cast % g++-11 -v
Using built-in specs.
COLLECT_GCC=g++-11
COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc/11.2.0_3/libexec/gcc/aarch64-apple-darwin21/11/lto-wrapper
Target: aarch64-apple-darwin21
Configured with: ../configure --prefix=/opt/homebrew/Cellar/gcc/11.2.0_3
--libdir=/opt/homebrew/Cellar/gcc/11.2.0_3/lib/gcc/11 --disable-nls
--enable-checking=release --with-gcc-major-version-only
--enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-11
--with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr
--with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl
--with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 11.2.0_3'
--with-bugurl=https://github.com/Homebrew/homebrew-core/issues
--build=aarch64-apple-darwin21 --with-system-zlib --disable-multilib
--with-native-system-header-dir=/usr/include
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Homebrew GCC 11.2.0_3)

Reply via email to