Re: Strange exception handling behaviour with dlopen()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* 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.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux