public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/68051] New: copy constructor does not copy default initialized union member
@ 2015-10-22 15:24 akju at mailinator dot com
  2015-10-22 16:59 ` [Bug c++/68051] " trippels at gcc dot gnu.org
  2015-10-22 17:18 ` trippels at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: akju at mailinator dot com @ 2015-10-22 15:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68051

            Bug ID: 68051
           Summary: copy constructor does not copy default initialized
                    union member
           Product: gcc
           Version: 5.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: akju at mailinator dot com
  Target Milestone: ---

The assertion at the end of the following code fails erroneously:

#include <string>
#include <cassert>

struct test
{
        union {int v = 0;};
        std::string dummy;
};

int main ()
{
        test x;
        x.v = 1;
        test y = x;
        assert (y.v == 1);
}

According to the assembly listing, it seems that the copy construction of y
uses the default member initializer of v instead of x.v. This behaviour does
not occur if the dummy member is removed causing the struct to be trivially
copyable.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/68051] copy constructor does not copy default initialized union member
  2015-10-22 15:24 [Bug c++/68051] New: copy constructor does not copy default initialized union member akju at mailinator dot com
@ 2015-10-22 16:59 ` trippels at gcc dot gnu.org
  2015-10-22 17:18 ` trippels at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-10-22 16:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68051

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |trippels at gcc dot gnu.org

--- Comment #1 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
This issue was fixed on trunk recently. The fix will hopefully be backported
to gcc-5.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/68051] copy constructor does not copy default initialized union member
  2015-10-22 15:24 [Bug c++/68051] New: copy constructor does not copy default initialized union member akju at mailinator dot com
  2015-10-22 16:59 ` [Bug c++/68051] " trippels at gcc dot gnu.org
@ 2015-10-22 17:18 ` trippels at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-10-22 17:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68051

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
It is already fixed.

*** This bug has been marked as a duplicate of bug 66583 ***


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-22 17:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-22 15:24 [Bug c++/68051] New: copy constructor does not copy default initialized union member akju at mailinator dot com
2015-10-22 16:59 ` [Bug c++/68051] " trippels at gcc dot gnu.org
2015-10-22 17:18 ` trippels at gcc dot gnu.org

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