public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102777] New: Error when requires expressions with parameter pack
@ 2021-10-15 12:51 ispavlick at gmail dot com
  2021-10-15 13:30 ` [Bug c++/102777] " redi at gcc dot gnu.org
  2021-10-15 23:31 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: ispavlick at gmail dot com @ 2021-10-15 12:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102777
           Summary: Error when requires expressions with parameter pack
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ispavlick at gmail dot com
  Target Milestone: ---

// clang compiles without errors.
#include <tuple>
#include <type_traits>
#include <iostream>
using namespace std;

template <typename T>
constexpr bool check_visitor = []<size_t ...I>(index_sequence<I...>){
            return ((requires (tuple_element_t<I, T> fun)
                                        {{fun(3)}->same_as<void>;}) && ...);
}(make_index_sequence<tuple_size_v<T>>{});

int main() {
        auto f1 = [](int) {};
        auto f2 = [](int) {};
        static_assert(check_visitor<tuple<decltype(f1), decltype(f2)>>);
}


$ g++ -std=c++20 1.cpp
1.cpp: In lambda function:
1.cpp:9:22: error: operand of fold expression has no unexpanded parameter packs
    9 |             return ((requires (tuple_element_t<I, T> fun)
      |                     ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   10 |                                         {{fun(3)}->same_as<void>;}) &&
...);
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.cpp: In instantiation of ‘constexpr const bool
check_visitor<std::tuple<main()::<lambda(int)>, main()::<lambda(int)> > >’:
1.cpp:16:16:   required from here
1.cpp:11:2: error: void value not ignored as it ought to be
    8 | constexpr bool check_visitor = []<size_t ...I>(index_sequence<I...>){
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    9 |             return ((requires (tuple_element_t<I, T> fun)
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   10 |                                         {{fun(3)}->same_as<void>;}) &&
...);
      |                                        
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   11 | }(make_index_sequence<tuple_size_v<T>>{});
      | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.cpp: In function ‘int main()’:
1.cpp:16:23: error: non-constant condition for static assertion
   16 |         static_assert(check_visitor<tuple<decltype(f1),
decltype(f2)>>);
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

* [Bug c++/102777] Error when requires expressions with parameter pack
  2021-10-15 12:51 [Bug c++/102777] New: Error when requires expressions with parameter pack ispavlick at gmail dot com
@ 2021-10-15 13:30 ` redi at gcc dot gnu.org
  2021-10-15 23:31 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2021-10-15 13:30 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-10-15
             Status|UNCONFIRMED                 |NEW

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

* [Bug c++/102777] Error when requires expressions with parameter pack
  2021-10-15 12:51 [Bug c++/102777] New: Error when requires expressions with parameter pack ispavlick at gmail dot com
  2021-10-15 13:30 ` [Bug c++/102777] " redi at gcc dot gnu.org
@ 2021-10-15 23:31 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-15 23:31 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 99594.

*** This bug has been marked as a duplicate of bug 99594 ***

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

end of thread, other threads:[~2021-10-15 23:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15 12:51 [Bug c++/102777] New: Error when requires expressions with parameter pack ispavlick at gmail dot com
2021-10-15 13:30 ` [Bug c++/102777] " redi at gcc dot gnu.org
2021-10-15 23:31 ` pinskia 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).