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

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