public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106614] New: GCC skips using copy constructor when creating object using direct initialization in A a({A{}});
@ 2022-08-14 15:28 jlame646 at gmail dot com
  0 siblings, 0 replies; only message in thread
From: jlame646 at gmail dot com @ 2022-08-14 15:28 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106614
           Summary: GCC skips using copy constructor when creating object
                    using direct initialization in A a({A{}});
           Product: gcc
           Version: 12.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlame646 at gmail dot com
  Target Milestone: ---

The following program prints `0` instead of `1` with gcc.
https://gcc.godbolt.org/z/WEz336E3r

```
#include <iostream>

struct A {
    int v = 0;
    A() {}
    A(const A &) : v(1) {}
};

int main() {
    A a({A{}});
    std::cout << a.v;  //this prints 0 in gcc instead of 1
}
```

The above program should print `0` as per dcl.init#17.6. The same program is
discussed here: https://stackoverflow.com/q/73345030/12002570

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-14 15:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-14 15:28 [Bug c++/106614] New: GCC skips using copy constructor when creating object using direct initialization in A a({A{}}); jlame646 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).