libstdc++: Attempt to resolve PR83562
Liu Hao
lh_mouse@126.com
Thu Oct 8 15:54:12 GMT 2020
在 2020/10/8 22:56, Jason Merrill 写道:
> On 10/7/20 10:52 PM, Liu Hao via Gcc-patches wrote:
>> [Please CC me as I am not subscribed to this list.]
>
> Hmm, why isn't the mingw implementation used for all programs? That would avoid the bug.
>
I am afraid the libstdc++ implementation has to be kept for compatibility, as the mingw-w64 one was only added two years
ago. Neither am I clear about MinGW.org.
>
> This patch is a good start but won't actually fix the bug: the calling convention only makes a difference when we actually
> call the function, at the line
>
> e->destructor (e->object);
>
> in atexit_thread.cc, and your patch doesn't change the calling convention for elt::destructor.
>
> I'd think we should add the attribute to __cxa_cdtor_type, and use it more consistently for __cxa_*atexit and __cxa_throw.
>
This patch contains a hunk
```diff
@@ -52,7 +57,7 @@ namespace {
// One element in a singly-linked stack of cleanups.
struct elt
{
- void (*destructor)(void *);
+ void (_GLIBCXX_CDTOR_CALLABI *destructor)(void *);
void *object;
elt *next;
#ifdef _GLIBCXX_THREAD_ATEXIT_WIN32
```
which should suffice. I am not against introduction of another macro for this calling convention thing, as the name
`__cxa_thread_atexit()` doesn't suggest its first argument is a non-static member function. (Technically I think it should
not be, so GCC's use of it to register the destructor looks like a bug. The call should go through a thunk.)
--
Best regards,
LH_Mouse
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20201008/a5261293/attachment.sig>
More information about the Gcc-patches
mailing list