Skip to content

Commit ca070a0

Browse files
Update flang/include/flang/Common/variant.h
Co-authored-by: Michael Kruse <github@meinersbur.de>
1 parent f1befb2 commit ca070a0

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

flang/include/flang/Common/variant.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ using cuda::std::visit;
2929
// directly and which defines a macro we need to redefine.
3030
#include <initializer_list>
3131

32-
// Redefine problematic abort macro to avoid defining symbols related to
33-
// std::exception. std::exception is defined in the C++ runtime library, which
34-
// we do not want the Fortran runtime library to depend on.
32+
// The macro _GLIBCXX_THROW_OR_ABORT is used by libstdc++ to not throw exceptions in -fno-exceptions mode, but immediatly kill the program. Since libstdc++ 15.1 the macro uses (void)(_EXC) after calling abort() to silence compiler warnings of an parameter. In its use in <variant>, _EXC is the construction of `std::bad_variant_access`. In non-optimized builds, some compilers including Clang will emit a call to that constructor. The constructor is implemented in libstdc++.a/.so which Flang-RT must not depend on (to avoid compatibility problems if a Fortran application itself has parts implemented in C++). Note that _GLIBCXX_THROW_OR_ABORT is not on the list of libstdc++'s documented user-configurable macros.
3533
#undef _GLIBCXX_THROW_OR_ABORT
3634
#define _GLIBCXX_THROW_OR_ABORT(_EXC) (__builtin_abort())
3735

0 commit comments

Comments
 (0)