public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/111172] New: Dead code in std::get for variant?
@ 2023-08-27 15:19 hewillk at gmail dot com
  2023-09-12 20:24 ` [Bug libstdc++/111172] " redi at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: hewillk at gmail dot com @ 2023-08-27 15:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111172
           Summary: Dead code in std::get for variant?
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

In libstdc++'s implementation of variant's std::get, there are static_asserts
that require T not to be void, for example:


    template<typename _Tp, typename... _Types>
    constexpr _Tp&
    get(variant<_Types...>& __v)
    {
      static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
                    "T must occur exactly once in alternatives");
      static_assert(!is_void_v<_Tp>, "_Tp must not be void");
      constexpr size_t __n = std::__find_uniq_type_in_pack<_Tp, _Types...>();
      return std::get<__n>(__v);
    }

But it looks like such static_asserts are *never* fired because the return type
already causes a compile error of forming reference to void when T is void.

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

* [Bug libstdc++/111172] Dead code in std::get for variant?
  2023-08-27 15:19 [Bug libstdc++/111172] New: Dead code in std::get for variant? hewillk at gmail dot com
@ 2023-09-12 20:24 ` redi at gcc dot gnu.org
  2023-09-15  9:24 ` cvs-commit at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2023-09-12 20:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-09-12
             Status|UNCONFIRMED                 |NEW

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

* [Bug libstdc++/111172] Dead code in std::get for variant?
  2023-08-27 15:19 [Bug libstdc++/111172] New: Dead code in std::get for variant? hewillk at gmail dot com
  2023-09-12 20:24 ` [Bug libstdc++/111172] " redi at gcc dot gnu.org
@ 2023-09-15  9:24 ` cvs-commit at gcc dot gnu.org
  2023-09-17 21:03 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-09-15  9:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from CVS 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:d19bdf8874059457fdfe50a9e14dad8f8b8cecbb

commit r14-4012-gd19bdf8874059457fdfe50a9e14dad8f8b8cecbb
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Sep 12 21:28:38 2023 +0100

    libstdc++: Remove non-void static assertions in variant's std::get
[PR111172]

    A void template argument would cause a substitution failure when trying
    to form a reference for the return type, so the function body would
    never be instantiated.

    libstdc++-v3/ChangeLog:

            PR libstdc++/111172
            * include/std/variant (get<T>): Remove !is_void static
            assertions.

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

* [Bug libstdc++/111172] Dead code in std::get for variant?
  2023-08-27 15:19 [Bug libstdc++/111172] New: Dead code in std::get for variant? hewillk at gmail dot com
  2023-09-12 20:24 ` [Bug libstdc++/111172] " redi at gcc dot gnu.org
  2023-09-15  9:24 ` cvs-commit at gcc dot gnu.org
@ 2023-09-17 21:03 ` redi at gcc dot gnu.org
  2023-11-09  8:09 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2023-09-17 21:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |14.0

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for GCC 14. Thanks for the report.

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

* [Bug libstdc++/111172] Dead code in std::get for variant?
  2023-08-27 15:19 [Bug libstdc++/111172] New: Dead code in std::get for variant? hewillk at gmail dot com
                   ` (2 preceding siblings ...)
  2023-09-17 21:03 ` redi at gcc dot gnu.org
@ 2023-11-09  8:09 ` cvs-commit at gcc dot gnu.org
  2023-11-09 10:02 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-09  8:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:9847a4e9f025e66bfd09e0174e8bd32aa01939af

commit r13-8021-g9847a4e9f025e66bfd09e0174e8bd32aa01939af
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Sep 12 21:28:38 2023 +0100

    libstdc++: Remove non-void static assertions in variant's std::get
[PR111172]

    A void template argument would cause a substitution failure when trying
    to form a reference for the return type, so the function body would
    never be instantiated.

    libstdc++-v3/ChangeLog:

            PR libstdc++/111172
            * include/std/variant (get<T>): Remove !is_void static
            assertions.

    (cherry picked from commit d19bdf8874059457fdfe50a9e14dad8f8b8cecbb)

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

* [Bug libstdc++/111172] Dead code in std::get for variant?
  2023-08-27 15:19 [Bug libstdc++/111172] New: Dead code in std::get for variant? hewillk at gmail dot com
                   ` (3 preceding siblings ...)
  2023-11-09  8:09 ` cvs-commit at gcc dot gnu.org
@ 2023-11-09 10:02 ` redi at gcc dot gnu.org
  2024-03-18 14:06 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2023-11-09 10:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|14.0                        |13.3

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

* [Bug libstdc++/111172] Dead code in std::get for variant?
  2023-08-27 15:19 [Bug libstdc++/111172] New: Dead code in std::get for variant? hewillk at gmail dot com
                   ` (4 preceding siblings ...)
  2023-11-09 10:02 ` redi at gcc dot gnu.org
@ 2024-03-18 14:06 ` cvs-commit at gcc dot gnu.org
  2024-03-18 14:15 ` redi at gcc dot gnu.org
  2024-03-18 14:16 ` redi at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-18 14:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:15c517049c0d8b6319990445939a69bb36fdc678

commit r12-10253-g15c517049c0d8b6319990445939a69bb36fdc678
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Sep 12 21:28:38 2023 +0100

    libstdc++: Remove non-void static assertions in variant's std::get
[PR111172]

    A void template argument would cause a substitution failure when trying
    to form a reference for the return type, so the function body would
    never be instantiated.

    libstdc++-v3/ChangeLog:

            PR libstdc++/111172
            * include/std/variant (get<T>): Remove !is_void static
            assertions.

    (cherry picked from commit d19bdf8874059457fdfe50a9e14dad8f8b8cecbb)

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

* [Bug libstdc++/111172] Dead code in std::get for variant?
  2023-08-27 15:19 [Bug libstdc++/111172] New: Dead code in std::get for variant? hewillk at gmail dot com
                   ` (5 preceding siblings ...)
  2024-03-18 14:06 ` cvs-commit at gcc dot gnu.org
@ 2024-03-18 14:15 ` redi at gcc dot gnu.org
  2024-03-18 14:16 ` redi at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-18 14:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 13.3 and 12.4 too.

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

* [Bug libstdc++/111172] Dead code in std::get for variant?
  2023-08-27 15:19 [Bug libstdc++/111172] New: Dead code in std::get for variant? hewillk at gmail dot com
                   ` (6 preceding siblings ...)
  2024-03-18 14:15 ` redi at gcc dot gnu.org
@ 2024-03-18 14:16 ` redi at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-18 14:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|13.3                        |12.4

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

end of thread, other threads:[~2024-03-18 14:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-27 15:19 [Bug libstdc++/111172] New: Dead code in std::get for variant? hewillk at gmail dot com
2023-09-12 20:24 ` [Bug libstdc++/111172] " redi at gcc dot gnu.org
2023-09-15  9:24 ` cvs-commit at gcc dot gnu.org
2023-09-17 21:03 ` redi at gcc dot gnu.org
2023-11-09  8:09 ` cvs-commit at gcc dot gnu.org
2023-11-09 10:02 ` redi at gcc dot gnu.org
2024-03-18 14:06 ` cvs-commit at gcc dot gnu.org
2024-03-18 14:15 ` redi at gcc dot gnu.org
2024-03-18 14:16 ` 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).