* Jonathan Wakely via Gcc-help: > On Tue, 17 Nov 2020 at 18:58, David Hagood via Gcc-help > <gcc-help@xxxxxxxxxxx> wrote: >> >> You are squarely into "undefined behavior" territory here: >> >> >> > static int throw314() >> > { >> > std::cout << "throw314() called\n" << std::flush; >> > throw 3.14f; >> > } >> > >> > static int throwDuringInitialization = throw314(); >> >> You are throwing from a constructor. That's STRONGLY discouraged - it > > No it isn't. > >> leads to undefined behavior, > > No it doesn't. The code throws from an *ELF* constructor (although it uses a C++ constructor to achieve this). This is currently not supported by the glibc implementation. It's possible to correct this. A really clean solution would require that we move the unwinder into glibc. Maybe it is possible to get the desired effect by using the unwinder that was just loaded to catch the exception, but that seems rather tricky.