[Bug c++/121068] Placement new of array element is rejected at compile-time

2025-07-21 Thread jason at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121068 Jason Merrill changed: What|Removed |Added Ever confirmed|0 |1 Status|UNCONFIRMED

[Bug c++/121068] Placement new of array element is rejected at compile-time

2025-07-17 Thread tkaminsk at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121068 --- Comment #7 from Tomasz Kamiński --- Or in other words, I believe my example is equivalent to implementation of optional, where we have: union { T val; }; And then call: new(static_cast(addressof(val))) T(...); It is just version were T

[Bug c++/121068] Placement new of array element is rejected at compile-time

2025-07-17 Thread tkaminsk at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121068 --- Comment #6 from Tomasz Kamiński --- I believed that `_member` being active after new should directly fall from the definition of active member in https://eel.is/c++draft/class.union#general-2: > In a union, a non-static data member is active

[Bug c++/121068] Placement new of array element is rejected at compile-time

2025-07-17 Thread jason at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121068 --- Comment #5 from Jason Merrill --- The intent of the patch was to support new (&union_.member) T syntax like union_.member = T() for setting the active member, as in https://eel.is/c++draft/class.union#general-example-3 but adding the li

[Bug c++/121068] Placement new of array element is rejected at compile-time

2025-07-17 Thread tkaminsk at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121068 --- Comment #4 from Tomasz Kamiński --- Hi, the original example works, but when I start to add library fluff, I get the same error. I mean cases like: // passing address to actual member new(&arr) T[3]; new(std::addressof(arr)) T[3]; // Disable

[Bug c++/121068] Placement new of array element is rejected at compile-time

2025-07-16 Thread jason at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121068 --- Comment #3 from Jason Merrill --- Created attachment 61891 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61891&action=edit fix Let me know how this works for you.

[Bug c++/121068] Placement new of array element is rejected at compile-time

2025-07-16 Thread tkaminsk at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121068 --- Comment #2 from Tomasz Kamiński --- That is indeed very surprising, as it would mean that if I have: ``` struct S { union { int x; }; }; constexpr S test() { S s; new(&s.x) int; is_active_member(s.x); // this is false } ``` On

[Bug c++/121068] Placement new of array element is rejected at compile-time

2025-07-16 Thread jason at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121068 Jason Merrill changed: What|Removed |Added CC||jason at gcc dot gnu.org --- Comment #1