public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114076] New: list-initialization with assignment expression triggers wrong template instanciation
@ 2024-02-23 12:17 benni.buch at gmail dot com
  2024-02-23 14:42 ` [Bug c++/114076] " de34 at live dot cn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: benni.buch at gmail dot com @ 2024-02-23 12:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114076
           Summary: list-initialization with assignment expression
                    triggers wrong template instanciation
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: benni.buch at gmail dot com
  Target Milestone: ---

I come from this Bug Report to Visual C++:

- https://github.com/microsoft/STL/issues/4417

I think that GCC has a similar bug here.

```cpp
template <typename T>
struct holder {
    holder() = default;

    constexpr ~holder() {
        static_assert(sizeof(T) || true);
    }
};

struct Incomplete;

struct Class {
    Class();
    ~Class();

    holder<Incomplete> a{};
    holder<Incomplete> b = {};
    //holder<Incomplete> c = holder<Incomplete>{};
};

int main() {
    [[maybe_unused]] Class v;
}
```

- https://godbolt.org/z/ds3WYK55f

Cases a and b can both be compiled with Clang. GCC rejects b, which is wrong in
my opinion.

If I understand it correctly, then cases a and b should result in absolutely
identical initializations. The destructor of holder should not be instantiated.

In case c, the rejection seems to me to be correct, since here the temporary
value must be destroyed by a destructor call.

Among other things, this error affects unique_ptr.

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

end of thread, other threads:[~2024-03-05 12:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-23 12:17 [Bug c++/114076] New: list-initialization with assignment expression triggers wrong template instanciation benni.buch at gmail dot com
2024-02-23 14:42 ` [Bug c++/114076] " de34 at live dot cn
2024-02-23 14:47 ` de34 at live dot cn
2024-03-05 12:26 ` benni.buch 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).