public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109425] New: mismatched argument pack lengths while expanding
@ 2023-04-05 19:53 h2+bugs at fsfe dot org
  2023-04-05 20:16 ` [Bug c++/109425] " mpolacek at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: h2+bugs at fsfe dot org @ 2023-04-05 19:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109425
           Summary: mismatched argument pack lengths while expanding
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: h2+bugs at fsfe dot org
  Target Milestone: ---

The following snippet is rejected by GCC10, GCC11 and GCC12:

```cpp
#include <concepts>

template <typename T1, typename T2>
concept weakly_eq_comparable = requires (T1 t1, T2 t2) { { t1 == t2 } ->
std::convertible_to<bool>; };

template <typename ...Ts>
struct my_tuple
{

    template <typename ...T2s>
    requires ((sizeof...(Ts) == sizeof...(T2s)) && (weakly_eq_comparable<Ts,
T2s> && ...))
    friend bool operator==(my_tuple const & lhs, my_tuple<T2s...> const & rhs)
    {
        return true;
    }
};

int main()
{
    my_tuple<int, float> m1;
}
```

See also:
https://godbolt.org/z/3eEjT589o

The error is:
```
<source>: In instantiation of 'struct my_tuple<int, float>':
<source>:20:26:   required from here
<source>:11:86: error: mismatched argument pack lengths while expanding
'weakly_eq_comparable<Ts, T2s>'
   11 |     requires ((sizeof...(Ts) == sizeof...(T2s)) &&
(weakly_eq_comparable<Ts, T2s> && ...))
      |                                                   
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
Compiler returned: 1
```

Clang>=13 accepts this code.

I am not sure if this is related to #107853, because I am not getting an ICE,
but it seems like the problems (or their solutions) could be related.

Thank you!

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

* [Bug c++/109425] mismatched argument pack lengths while expanding
  2023-04-05 19:53 [Bug c++/109425] New: mismatched argument pack lengths while expanding h2+bugs at fsfe dot org
@ 2023-04-05 20:16 ` mpolacek at gcc dot gnu.org
  2023-04-05 23:09 ` h2+bugs at fsfe dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-04-05 20:16 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Seems to have been fixed by r13-4876-gbd1fc4a219d8c0

commit bd1fc4a219d8c0fad0ec41002e895b49e384c1c2
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Dec 23 09:18:37 2022 -0500

    c++: template friend with variadic constraints [PR107853]

so it is related to bug 107853.  In fact I think we can say it's a dup.

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

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

* [Bug c++/109425] mismatched argument pack lengths while expanding
  2023-04-05 19:53 [Bug c++/109425] New: mismatched argument pack lengths while expanding h2+bugs at fsfe dot org
  2023-04-05 20:16 ` [Bug c++/109425] " mpolacek at gcc dot gnu.org
@ 2023-04-05 23:09 ` h2+bugs at fsfe dot org
  2023-04-06 13:18 ` mpolacek at gcc dot gnu.org
  2023-04-06 13:25 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: h2+bugs at fsfe dot org @ 2023-04-05 23:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Hannes Hauswedell <h2+bugs at fsfe dot org> ---
Thanks for the quick reply, and nice that it is already fixed for 13!

I assume this will not be backported? It wouldn't be a huge problem, because it
is possible to workaround with non-friend operators.

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

* [Bug c++/109425] mismatched argument pack lengths while expanding
  2023-04-05 19:53 [Bug c++/109425] New: mismatched argument pack lengths while expanding h2+bugs at fsfe dot org
  2023-04-05 20:16 ` [Bug c++/109425] " mpolacek at gcc dot gnu.org
  2023-04-05 23:09 ` h2+bugs at fsfe dot org
@ 2023-04-06 13:18 ` mpolacek at gcc dot gnu.org
  2023-04-06 13:25 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-04-06 13:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Hannes Hauswedell from comment #2)
> Thanks for the quick reply, and nice that it is already fixed for 13!
> 
> I assume this will not be backported? It wouldn't be a huge problem, because
> it is possible to workaround with non-friend operators.

I think this is up to Patrick to decide.

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

* [Bug c++/109425] mismatched argument pack lengths while expanding
  2023-04-05 19:53 [Bug c++/109425] New: mismatched argument pack lengths while expanding h2+bugs at fsfe dot org
                   ` (2 preceding siblings ...)
  2023-04-06 13:18 ` mpolacek at gcc dot gnu.org
@ 2023-04-06 13:25 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-04-06 13:25 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Hannes Hauswedell from comment #2)
> Thanks for the quick reply, and nice that it is already fixed for 13!
> 
> I assume this will not be backported? It wouldn't be a huge problem, because
> it is possible to workaround with non-friend operators.

It's already been backported to the 12 branch, so the upcoming GCC 12.3 (or a
recent enough snapshot of the release branch) will also include the fix.  No
decision yet about backporting to the 11/10 branches.  Having to work around
this by defining these functions as non-friends is pretty inconvenient..

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

end of thread, other threads:[~2023-04-06 13:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-05 19:53 [Bug c++/109425] New: mismatched argument pack lengths while expanding h2+bugs at fsfe dot org
2023-04-05 20:16 ` [Bug c++/109425] " mpolacek at gcc dot gnu.org
2023-04-05 23:09 ` h2+bugs at fsfe dot org
2023-04-06 13:18 ` mpolacek at gcc dot gnu.org
2023-04-06 13:25 ` ppalka 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).