public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dani at danielbertalan dot dev" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/109683] New: [13/14 Regression] False cyclic dependency error reported for constraint
Date: Mon, 01 May 2023 09:43:36 +0000	[thread overview]
Message-ID: <bug-109683-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             reply	other threads:[~2023-05-01  9:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-01  9:43 dani at danielbertalan dot dev [this message]
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
2024-05-21  9:14 ` [Bug c++/109683] [13/14/15 " jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109683-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).