public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100185] New: transparent_union fails when the union has a destructor
@ 2021-04-21 15:49 gonzalobg88 at gmail dot com
2021-04-21 15:56 ` [Bug c++/100185] " jakub at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: gonzalobg88 at gmail dot com @ 2021-04-21 15:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100185
Bug ID: 100185
Summary: transparent_union fails when the union has a
destructor
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gonzalobg88 at gmail dot com
Target Milestone: ---
Example:
union __attribute__((transparent_union)) U {
int* a;
~U() {}
};
fails with:
<source>:1:43: error: type transparent 'union U' cannot be made transparent
because the type of the first field has a different ABI from the class
overall
1 | union __attribute__((transparent_union)) U {
| ^
I think this should be allowed with the following semantics:
void f(int*);
void g(U&);
void h(U);
void j(int);
{
U u;
f(u); // passes U as int*
g(u); // passes U as U&
h(u); // ERROR: U does not have a copy constructor
j(u); // ERROR: cannot convert U to int
//~U() called at the end of the scope
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/100185] transparent_union fails when the union has a destructor
2021-04-21 15:49 [Bug c++/100185] New: transparent_union fails when the union has a destructor gonzalobg88 at gmail dot com
@ 2021-04-21 15:56 ` jakub at gcc dot gnu.org
2021-04-22 7:28 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-21 15:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100185
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think the error is right and desirable. Types with non-trivial ctors or
dtors need to be passed by invisible reference, so can't be passed the same as
the first union member.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/100185] transparent_union fails when the union has a destructor
2021-04-21 15:49 [Bug c++/100185] New: transparent_union fails when the union has a destructor gonzalobg88 at gmail dot com
2021-04-21 15:56 ` [Bug c++/100185] " jakub at gcc dot gnu.org
@ 2021-04-22 7:28 ` rguenth at gcc dot gnu.org
2021-04-22 14:34 ` gonzalo.gadeschi at gmail dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-22 7:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100185
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
indeed
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/100185] transparent_union fails when the union has a destructor
2021-04-21 15:49 [Bug c++/100185] New: transparent_union fails when the union has a destructor gonzalobg88 at gmail dot com
2021-04-21 15:56 ` [Bug c++/100185] " jakub at gcc dot gnu.org
2021-04-22 7:28 ` rguenth at gcc dot gnu.org
@ 2021-04-22 14:34 ` gonzalo.gadeschi at gmail dot com
2021-04-22 14:46 ` jakub at gcc dot gnu.org
2021-04-22 16:52 ` gonzalo.gadeschi at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: gonzalo.gadeschi at gmail dot com @ 2021-04-22 14:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100185
--- Comment #3 from gnzlbg <gonzalo.gadeschi at gmail dot com> ---
@Jakub, is there a GCC equivalent to `[[clang::trivial_abi]]` that one can use
instead ?
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/100185] transparent_union fails when the union has a destructor
2021-04-21 15:49 [Bug c++/100185] New: transparent_union fails when the union has a destructor gonzalobg88 at gmail dot com
` (2 preceding siblings ...)
2021-04-22 14:34 ` gonzalo.gadeschi at gmail dot com
@ 2021-04-22 14:46 ` jakub at gcc dot gnu.org
2021-04-22 16:52 ` gonzalo.gadeschi at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-22 14:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100185
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
No and I think it is quite bad idea.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/100185] transparent_union fails when the union has a destructor
2021-04-21 15:49 [Bug c++/100185] New: transparent_union fails when the union has a destructor gonzalobg88 at gmail dot com
` (3 preceding siblings ...)
2021-04-22 14:46 ` jakub at gcc dot gnu.org
@ 2021-04-22 16:52 ` gonzalo.gadeschi at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: gonzalo.gadeschi at gmail dot com @ 2021-04-22 16:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100185
--- Comment #5 from gnzlbg <gonzalo.gadeschi at gmail dot com> ---
Thank you for the clarification! Will map Rust repr(transparent) to clang's
[[clang::trivial_abi]] then and will gracefully #pragma error to prevent users
from shooting themselves in the foot with GCC.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-04-22 16:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-21 15:49 [Bug c++/100185] New: transparent_union fails when the union has a destructor gonzalobg88 at gmail dot com
2021-04-21 15:56 ` [Bug c++/100185] " jakub at gcc dot gnu.org
2021-04-22 7:28 ` rguenth at gcc dot gnu.org
2021-04-22 14:34 ` gonzalo.gadeschi at gmail dot com
2021-04-22 14:46 ` jakub at gcc dot gnu.org
2021-04-22 16:52 ` gonzalo.gadeschi at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).