public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/116381] New: std::variant should not allow array type as an alternative
@ 2024-08-15  9:18 m at tryfinally dot com
  2024-08-20 10:35 ` [Bug libstdc++/116381] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: m at tryfinally dot com @ 2024-08-15  9:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 116381
           Summary: std::variant should not allow array type as an
                    alternative
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: m at tryfinally dot com
  Target Milestone: ---

Created attachment 58930
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58930&action=edit
minimal code which should not compile but does

std::variant requires all alternative types to be Cpp17Destructible. See 
https://eel.is/c++draft/variant#variant.general-2

arrays are not Cpp17Destructible.
https://eel.is/c++draft/utility.arg.requirements#:Cpp17Destructible

#include <variant>

std::variant<int[3]> v; // should fail to compile

godbolt: https://godbolt.org/z/PvTja54PE

this behavior goes back to GCC 7.1

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

* [Bug libstdc++/116381] std::variant should not allow array type as an alternative
  2024-08-15  9:18 [Bug libstdc++/116381] New: std::variant should not allow array type as an alternative m at tryfinally dot com
@ 2024-08-20 10:35 ` redi at gcc dot gnu.org
  2024-08-20 10:38 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2024-08-20 10:35 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-08-20
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This rule was added by
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0510r0.html to
address C++17 ballot comments. It looks like we never implemented that change.

https://cplusplus.github.io/LWG/issue3196  adjusted the wording slightly, but
without altering the semantics.

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

* [Bug libstdc++/116381] std::variant should not allow array type as an alternative
  2024-08-15  9:18 [Bug libstdc++/116381] New: std::variant should not allow array type as an alternative m at tryfinally dot com
  2024-08-20 10:35 ` [Bug libstdc++/116381] " redi at gcc dot gnu.org
@ 2024-08-20 10:38 ` redi at gcc dot gnu.org
  2024-08-21  8:53 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2024-08-20 10:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Actually g:7b277e8b464b seems to have partially implemented it, but without
rejecting arrays.

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

* [Bug libstdc++/116381] std::variant should not allow array type as an alternative
  2024-08-15  9:18 [Bug libstdc++/116381] New: std::variant should not allow array type as an alternative m at tryfinally dot com
  2024-08-20 10:35 ` [Bug libstdc++/116381] " redi at gcc dot gnu.org
  2024-08-20 10:38 ` redi at gcc dot gnu.org
@ 2024-08-21  8:53 ` cvs-commit at gcc dot gnu.org
  2024-08-21  8:58 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-08-21  8:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:1e10b3b8825ee398f077500af6ae1f5db180983a

commit r15-3065-g1e10b3b8825ee398f077500af6ae1f5db180983a
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Aug 20 16:52:22 2024 +0100

    libstdc++: Fix std::variant to reject array types [PR116381]

    libstdc++-v3/ChangeLog:

            PR libstdc++/116381
            * include/std/variant (variant): Fix conditions for
            static_assert to match the spec.
            * testsuite/20_util/variant/types_neg.cc: New test.

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

* [Bug libstdc++/116381] std::variant should not allow array type as an alternative
  2024-08-15  9:18 [Bug libstdc++/116381] New: std::variant should not allow array type as an alternative m at tryfinally dot com
                   ` (2 preceding siblings ...)
  2024-08-21  8:53 ` cvs-commit at gcc dot gnu.org
@ 2024-08-21  8:58 ` redi at gcc dot gnu.org
  2024-09-04 20:35 ` cvs-commit at gcc dot gnu.org
  2024-09-04 20:40 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2024-08-21  8:58 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|---                         |15.0
         Resolution|---                         |FIXED

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for GCC 15. I'm considering backporting this to release branches too.

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

* [Bug libstdc++/116381] std::variant should not allow array type as an alternative
  2024-08-15  9:18 [Bug libstdc++/116381] New: std::variant should not allow array type as an alternative m at tryfinally dot com
                   ` (3 preceding siblings ...)
  2024-08-21  8:58 ` redi at gcc dot gnu.org
@ 2024-09-04 20:35 ` cvs-commit at gcc dot gnu.org
  2024-09-04 20:40 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-09-04 20:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:3b8a67b0cfc072f027eab24fb72d48d10cc890b4

commit r14-10636-g3b8a67b0cfc072f027eab24fb72d48d10cc890b4
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Aug 20 16:52:22 2024 +0100

    libstdc++: Fix std::variant to reject array types [PR116381]

    For the backport, rejecting array types is only done in strict modes.

    libstdc++-v3/ChangeLog:

            PR libstdc++/116381
            * include/std/variant (variant): Fix conditions for
            static_assert to match the spec.
            * testsuite/20_util/variant/types_neg.cc: New test.

    (cherry picked from commit 1e10b3b8825ee398f077500af6ae1f5db180983a)

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

* [Bug libstdc++/116381] std::variant should not allow array type as an alternative
  2024-08-15  9:18 [Bug libstdc++/116381] New: std::variant should not allow array type as an alternative m at tryfinally dot com
                   ` (4 preceding siblings ...)
  2024-09-04 20:35 ` cvs-commit at gcc dot gnu.org
@ 2024-09-04 20:40 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2024-09-04 20:40 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|15.0                        |14.3

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Backported for 14.3, but only checked for strict -std=c++NN modes, not
-std=gnu++NN

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

end of thread, other threads:[~2024-09-04 20:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-15  9:18 [Bug libstdc++/116381] New: std::variant should not allow array type as an alternative m at tryfinally dot com
2024-08-20 10:35 ` [Bug libstdc++/116381] " redi at gcc dot gnu.org
2024-08-20 10:38 ` redi at gcc dot gnu.org
2024-08-21  8:53 ` cvs-commit at gcc dot gnu.org
2024-08-21  8:58 ` redi at gcc dot gnu.org
2024-09-04 20:35 ` cvs-commit at gcc dot gnu.org
2024-09-04 20:40 ` redi 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).