public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109683] New: [13/14 Regression] False cyclic dependency error reported for constraint
@ 2023-05-01 9:43 dani at danielbertalan dot dev
2023-05-01 11:23 ` [Bug c++/109683] " ali.mpfard at gmail dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: dani at danielbertalan dot dev @ 2023-05-01 9:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109683
Bug ID: 109683
Summary: [13/14 Regression] False cyclic dependency error
reported for constraint
Product: gcc
Version: 13.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: dani at danielbertalan dot dev
Target Milestone: ---
The following code (reduced from a custom std::variant-like type) compiles with
GCC 12.2 and Clang, but is rejected by GCC 13+:
```
template <typename T, typename>
struct VariantConstructors {
VariantConstructors(T&& t)
requires(requires { T(t); });
};
template <typename... Ts>
struct InheritFromEntries : Ts... {};
template <typename... Ps>
struct InheritFromPack: InheritFromEntries<Ps>... {
using InheritFromEntries<Ps>::InheritFromEntries...;
};
template <typename... Ts>
struct Variant : InheritFromPack<VariantConstructors<Ts, Variant<Ts...>>...>
{};
template <typename T>
class Outer;
struct Inner {
Inner(Outer<int>);
};
template<typename T>
class Outer {
Variant<T, Inner> value_;
};
struct Empty {};
void fn(Outer<Empty> x) {}
```
The following compiler error is produced (arguments: -std=c++20):
<source>: In instantiation of 'VariantConstructors<T, <template-parameter-1-2>
>::VariantConstructors(T&&) requires requires{T(VariantConstructors<T,
<template-parameter-1-2> >::__ct ::t);} [with T = Inner;
<template-parameter-1-2> = Variant<int, Inner>]':
<source>:12:51: required from 'struct
InheritFromPack<VariantConstructors<int, Variant<int, Inner> >,
VariantConstructors<Inner, Variant<int, Inner> > >'
<source>:16:8: required from 'struct Variant<int, Inner>'
<source>:25:23: required from 'class Outer<int>'
<source>:4:25: required from 'VariantConstructors<T, <template-parameter-1-2>
>::VariantConstructors(T&&) requires requires{T(VariantConstructors<T,
<template-parameter-1-2> >::__ct ::t);} [with T = Inner;
<template-parameter-1-2> = Variant<Empty, Inner>]'
<source>:12:51: required from 'struct
InheritFromPack<VariantConstructors<Empty, Variant<Empty, Inner> >,
VariantConstructors<Inner, Variant<Empty, Inner> > >'
<source>:16:8: required from 'struct Variant<Empty, Inner>'
<source>:25:23: required from 'class Outer<Empty>'
<source>:29:23: required from here
<source>:3:3: required by the constraints of 'template<class T, class>
VariantConstructors<T, <template-parameter-1-2> >::VariantConstructors(T&&)
requires requires{T(VariantConstructors<T, <template-parameter-1-2> >::__ct
::t);}'
<source>:4:14: in requirements [with T = Inner]
<source>:4:14: error: satisfaction of atomic constraint
'requires{T(VariantConstructors<T, <template-parameter-1-2> >::__ct ::t);}
[with T = T]' depends on itself
4 | requires(requires { T(t); });
| ~^~~~~~~~~~~~~~~~~~~
Reproducer on Compiler Explorer: https://godbolt.org/z/TbcoanG5T
The non-reduced preprocessed source can be found here:
https://godbolt.org/z/69dMMoWKh
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/109683] [13/14 Regression] False cyclic dependency error reported for constraint
2023-05-01 9:43 [Bug c++/109683] New: [13/14 Regression] False cyclic dependency error reported for constraint dani at danielbertalan dot dev
@ 2023-05-01 11:23 ` ali.mpfard at gmail dot com
2023-05-01 11:58 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: ali.mpfard at gmail dot com @ 2023-05-01 11:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109683
Ali Mohammad Pur Fard <ali.mpfard at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ali.mpfard at gmail dot com
--- Comment #1 from Ali Mohammad Pur Fard <ali.mpfard at gmail dot com> ---
As a note, using a type alias for `T` in the constraint seems to work around
the issue:
```
template <typename T, typename>
struct VariantConstructors {
using U = T;
VariantConstructors(T&& t)
requires(requires { U(t); });
};
// Everything below is the same as the repro case
template <typename... Ts>
struct InheritFromEntries : Ts... {};
template <typename... Ps>
struct InheritFromPack: InheritFromEntries<Ps>... {
using InheritFromEntries<Ps>::InheritFromEntries...;
};
template <typename... Ts>
struct Variant : InheritFromPack<VariantConstructors<Ts, Variant<Ts...>>...>
{};
template <typename T>
class Outer;
struct Inner {
Inner(Outer<int>);
};
template<typename T>
class Outer {
Variant<T, Inner> value_;
};
struct Empty {};
void fn(Outer<Empty> x) {}
```
(https://godbolt.org/z/1GTrjcvG6)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/109683] [13/14 Regression] False cyclic dependency error reported for constraint
2023-05-01 9:43 [Bug c++/109683] New: [13/14 Regression] False cyclic dependency error reported for constraint dani at danielbertalan dot dev
2023-05-01 11:23 ` [Bug c++/109683] " ali.mpfard at gmail dot com
@ 2023-05-01 11:58 ` ppalka at gcc dot gnu.org
2023-05-02 6:25 ` rguenth at gcc dot gnu.org
2023-07-27 9:26 ` rguenth at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-05-01 11:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109683
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=105797
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Last reconfirmed| |2023-05-01
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
Keywords| |rejects-valid
Target Milestone|--- |13.2
CC| |ppalka at gcc dot gnu.org
--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Thanks for the bug report. Started with r13-980-gdf4f95dbd4764f which made
function parameters used in a constraint no longer induce a dependency on all
contextual template parameters.
So another workaround would be to make the constructor's constraints explicitly
depend on the second template parameter of the class:
template <typename T, typename U>
struct VariantConstructors {
VariantConstructors(T&& t)
requires(requires { T(t); typename U; });
};
...
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/109683] [13/14 Regression] False cyclic dependency error reported for constraint
2023-05-01 9:43 [Bug c++/109683] New: [13/14 Regression] False cyclic dependency error reported for constraint dani at danielbertalan dot dev
2023-05-01 11:23 ` [Bug c++/109683] " ali.mpfard at gmail dot com
2023-05-01 11:58 ` ppalka at gcc dot gnu.org
@ 2023-05-02 6:25 ` rguenth at gcc dot gnu.org
2023-07-27 9:26 ` rguenth at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-05-02 6:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109683
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/109683] [13/14 Regression] False cyclic dependency error reported for constraint
2023-05-01 9:43 [Bug c++/109683] New: [13/14 Regression] False cyclic dependency error reported for constraint dani at danielbertalan dot dev
` (2 preceding siblings ...)
2023-05-02 6:25 ` rguenth at gcc dot gnu.org
@ 2023-07-27 9:26 ` rguenth at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-27 9:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109683
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|13.2 |13.3
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 13.2 is being released, retargeting bugs to GCC 13.3.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-27 9:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-01 9:43 [Bug c++/109683] New: [13/14 Regression] False cyclic dependency error reported for constraint dani at danielbertalan dot dev
2023-05-01 11:23 ` [Bug c++/109683] " ali.mpfard at gmail dot com
2023-05-01 11:58 ` ppalka at gcc dot gnu.org
2023-05-02 6:25 ` rguenth at gcc dot gnu.org
2023-07-27 9:26 ` rguenth 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).