public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99599] New: Concepts requirement falsely reporting recursion, breaks tag_invoke pattern
@ 2021-03-15 13:24 the_gamester28 at msn dot com
  2021-03-15 13:49 ` [Bug c++/99599] [11 Regression] Concepts requirement falsely reporting cyclic dependency, " rguenth at gcc dot gnu.org
                   ` (26 more replies)
  0 siblings, 27 replies; 28+ messages in thread
From: the_gamester28 at msn dot com @ 2021-03-15 13:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99599
           Summary: Concepts requirement falsely reporting recursion,
                    breaks tag_invoke pattern
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: the_gamester28 at msn dot com
  Target Milestone: ---

The following code compiles fine on GCC 10, Clang, MSVC, but fails in GCC
11/trunk:

### begin

struct foo_tag{};
struct bar_tag{};

template <class T>
concept fooable = requires(T it) {
    invoke_tag(foo_tag{}, it); // <-- here
};

template<class T>
auto invoke_tag(foo_tag, T in) {
    return in;
}

template<fooable T>
auto invoke_tag(bar_tag, T it) {
    return it;
}

int main() {
    // Neither line below compiles in GCC 11, independently of the other
    return invoke_tag(foo_tag{}, 2);
    return invoke_tag(bar_tag{}, 2);
}

### end

Produces the following compiler error:

### begin

<source>: In substitution of 'template<class T>  requires  fooable<T> auto
invoke_tag(bar_tag, T) [with T = int]':
<source>:6:15:   required by substitution of 'template<class T>  requires 
fooable<T> auto invoke_tag(bar_tag, T) [with T = int]'
<source>:21:35:   required from here
<source>:5:9:   required for the satisfaction of 'fooable<T>' [with T = int]
<source>:5:19:   in requirements with 'T it' [with T = int]
<source>:5:19: error: satisfaction of atomic constraint 'requires(T it)
{invoke_tag({}, it);} [with T = T]' depends on itself
    5 | concept fooable = requires(T it) {
      |                   ^~~~~~~~~~~~~~~~
    6 |     invoke_tag(foo_tag{}, it);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~
    7 | };
      | ~                  

### end

It seems that the template requirements of invoke_tag(bar_tag, int) are
considered while evaluating line marked "here". Requirements of irrelevant
overloads should not be considered, as it can potentially lead to falsely
reporting a cyclic dependency.

This bug effectively prevents using the modern tag_invoke pattern, which is
increasingly used as a customisation point in many modern libraries.

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

end of thread, other threads:[~2024-03-27 23:18 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15 13:24 [Bug c++/99599] New: Concepts requirement falsely reporting recursion, breaks tag_invoke pattern the_gamester28 at msn dot com
2021-03-15 13:49 ` [Bug c++/99599] [11 Regression] Concepts requirement falsely reporting cyclic dependency, " rguenth at gcc dot gnu.org
2021-03-15 14:20 ` redi at gcc dot gnu.org
2021-04-01 22:04 ` jason at gcc dot gnu.org
2021-04-02 12:47 ` gcc-bugs at marehr dot dialup.fu-berlin.de
2021-04-05 19:49 ` the_gamester28 at msn dot com
2021-04-27 11:40 ` [Bug c++/99599] [11/12 " jakub at gcc dot gnu.org
2021-05-01 17:38 ` ppalka at gcc dot gnu.org
2021-07-28  7:06 ` rguenth at gcc dot gnu.org
2021-08-25 14:44 ` ppalka at gcc dot gnu.org
2022-04-21  7:48 ` rguenth at gcc dot gnu.org
2022-08-08 15:06 ` [Bug c++/99599] [11/12/13 " ppalka at gcc dot gnu.org
2022-10-27 12:42 ` ppalka at gcc dot gnu.org
2023-04-04  5:33 ` catsith at me dot com
2023-05-29 10:04 ` [Bug c++/99599] [11/12/13/14 " jakub at gcc dot gnu.org
2023-06-07 18:25 ` danakj at orodu dot net
2023-06-07 18:41 ` danakj at orodu dot net
2023-06-07 20:03 ` danakj at orodu dot net
2023-08-01 18:16 ` ppalka at gcc dot gnu.org
2023-09-08 16:03 ` cvs-commit at gcc dot gnu.org
2024-02-02 18:02 ` [Bug c++/99599] [11/12/13 " ppalka at gcc dot gnu.org
2024-03-09 15:37 ` ppalka at gcc dot gnu.org
2024-03-21 21:40 ` redi at gcc dot gnu.org
2024-03-21 21:43 ` redi at gcc dot gnu.org
2024-03-22 14:08 ` ppalka at gcc dot gnu.org
2024-03-22 15:58 ` redi at gcc dot gnu.org
2024-03-27 23:16 ` redi at gcc dot gnu.org
2024-03-27 23:18 ` redi 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).