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

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).