[Bug c++/126630] New: fold operand not expanded in return-type-requirement of requires expression
hanicka at hanicka dot net via Gcc-bugs <[email protected]> Tue, 04 Aug 2026 06:09:19 +0000
| Newsgroups | gmane.comp.gcc.bugs |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D126630
Bug ID: 126630
Summary: fold operand not expanded in return-type-requirement
of requires expression
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: hanicka at hanicka dot net
Target Milestone: ---
This behavior is in GCC since GCC 9.
```
template <typename, typename> concept always_true_with =3D true;
template <typename T, typename... Targets> concept bad_convertible_to =3D
(requires (const T & obj) {
{ obj } -> always_true_with<Targets>;
} && ...);
```
This returns error:
```
<source>:3:74: error: operand of fold expression has no unexpanded parameter
packs
3 | template <typename T, typename... Targets> concept bad_convertible_=
to =3D
(requires (const T & obj) {
|=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
^~~~~~~~~~~~~~~~~~~~~~~~~~
4 | { obj } -> always_true_with<Targets>;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
5 | } && ...);
| ~=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
```
Expected bahaviour it will fold whole requires-expression over operator &&,
each with different `Targets`. If the `Targets` is inside of the compound
statement, it works as expected.
Compiler Explorer link: https://compiler-explorer.com/z/d1PTc9MEn=