public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101677] New: [11 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward
@ 2021-07-29 15:58 joeloser93 at gmail dot com
  2021-07-30  6:13 ` [Bug c++/101677] [11/12 " rguenth at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: joeloser93 at gmail dot com @ 2021-07-29 15:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101677
           Summary: [11 Regression] Concept with use of incomplete type
                    succeeds on GCC 10.3.0, fails on GCC 11 onward
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: joeloser93 at gmail dot com
  Target Milestone: ---

A concept that uses an incomplete type in testing the well-formedness of
calling a function template is well-formed in GCC 10.3.0, but fails in GCC 11
onward (including trunk at the time of this writing).

For example, consider the following:

template<class T>
concept C_bug_with_forward_decl = requires(T& t){
    t.template f<class S>();
};

struct good {
    template<class T> auto f() -> void {}
};

static_assert(C_bug_with_forward_decl<good>); // works in GCC 10.3.0, fails on
GCC 11 onward

This bug can be worked around by using a complete type instead when defining
the concept. For example:

struct U{};
template<class T>
concept C_workaround = requires(T& t){
    t.template f<U>();
};

static_assert(C_workaround<good>); // works on GCC 10.3.0 and GCC 11 onward

See it live at https://godbolt.org/z/h7GzqGhYn

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

* [Bug c++/101677] [11/12 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward
  2021-07-29 15:58 [Bug c++/101677] New: [11 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward joeloser93 at gmail dot com
@ 2021-07-30  6:13 ` rguenth at gcc dot gnu.org
  2021-07-30  6:25 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-30  6:13 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11 Regression] Concept     |[11/12 Regression] Concept
                   |with use of incomplete type |with use of incomplete type
                   |succeeds on GCC 10.3.0,     |succeeds on GCC 10.3.0,
                   |fails on GCC 11 onward      |fails on GCC 11 onward
      Known to work|                            |10.3.0
   Target Milestone|---                         |11.3
           Keywords|                            |rejects-valid

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

* [Bug c++/101677] [11/12 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward
  2021-07-29 15:58 [Bug c++/101677] New: [11 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward joeloser93 at gmail dot com
  2021-07-30  6:13 ` [Bug c++/101677] [11/12 " rguenth at gcc dot gnu.org
@ 2021-07-30  6:25 ` pinskia at gcc dot gnu.org
  2021-07-30 15:50 ` joeloser93 at gmail dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-30  6:25 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-07-30

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>This bug can be worked around by using a complete type instead when defining the concept. 

It does not even have to be complete type; just defined before.
So adding:
class S;
at the begining causes GCC to accept the code.

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

* [Bug c++/101677] [11/12 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward
  2021-07-29 15:58 [Bug c++/101677] New: [11 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward joeloser93 at gmail dot com
  2021-07-30  6:13 ` [Bug c++/101677] [11/12 " rguenth at gcc dot gnu.org
  2021-07-30  6:25 ` pinskia at gcc dot gnu.org
@ 2021-07-30 15:50 ` joeloser93 at gmail dot com
  2022-01-17 13:59 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: joeloser93 at gmail dot com @ 2021-07-30 15:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Joe Loser <joeloser93 at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> >This bug can be worked around by using a complete type instead when defining the concept. 
> 
> It does not even have to be complete type; just defined before.
> So adding:
> class S;
> at the begining causes GCC to accept the code.

Yep, you're right. That's actually what I use in my codebase as a workaround. I
misspoke in the description -- sorry about that. Updated Godbolt link is at
https://godbolt.org/z/KGq48WYq4

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

* [Bug c++/101677] [11/12 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward
  2021-07-29 15:58 [Bug c++/101677] New: [11 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward joeloser93 at gmail dot com
                   ` (2 preceding siblings ...)
  2021-07-30 15:50 ` joeloser93 at gmail dot com
@ 2022-01-17 13:59 ` rguenth at gcc dot gnu.org
  2022-04-01 19:30 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-17 13:59 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug c++/101677] [11/12 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward
  2021-07-29 15:58 [Bug c++/101677] New: [11 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward joeloser93 at gmail dot com
                   ` (3 preceding siblings ...)
  2022-01-17 13:59 ` rguenth at gcc dot gnu.org
@ 2022-04-01 19:30 ` jason at gcc dot gnu.org
  2022-04-05 16:29 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2022-04-01 19:30 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |jason at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org

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

* [Bug c++/101677] [11/12 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward
  2021-07-29 15:58 [Bug c++/101677] New: [11 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward joeloser93 at gmail dot com
                   ` (4 preceding siblings ...)
  2022-04-01 19:30 ` jason at gcc dot gnu.org
@ 2022-04-05 16:29 ` cvs-commit at gcc dot gnu.org
  2022-04-12 20:14 ` [Bug c++/101677] [11 " cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-05 16:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:1de6612d994ada8edaab18bbc6afd8e9a57413aa

commit r12-7997-g1de6612d994ada8edaab18bbc6afd8e9a57413aa
Author: Jason Merrill <jason@redhat.com>
Date:   Sun Mar 27 22:31:51 2022 -0400

    c++: elaborated-type-spec in requires-expr [PR101677]

    We were failing to declare class S in the global namespace because we were
    treating the requires-expression parameter scope as a normal block scope,
so
    the implicit declaration went there.

    It seems to me that the requires parameter scope is more like a function
    parameter scope (not least in the use of the word "parameter"), so let's
    change the scope kind.  But then we need to adjust the prohibition on
    placeholders declaring implicit template parameters.

            PR c++/101677

    gcc/cp/ChangeLog:

            * name-lookup.h (struct cp_binding_level): Add requires_expression
            bit-field.
            * parser.cc (cp_parser_requires_expression): Set it.
            (synthesize_implicit_template_parm): Check it.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-pr67178.C: Adjust error.
            * g++.dg/cpp2a/concepts-requires28.C: New test.

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

* [Bug c++/101677] [11 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward
  2021-07-29 15:58 [Bug c++/101677] New: [11 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward joeloser93 at gmail dot com
                   ` (5 preceding siblings ...)
  2022-04-05 16:29 ` cvs-commit at gcc dot gnu.org
@ 2022-04-12 20:14 ` cvs-commit at gcc dot gnu.org
  2022-04-12 20:22 ` jason at gcc dot gnu.org
  2023-06-09 14:36 ` ppalka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-12 20:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:556d061e62ea863c7f99129219ca69bf0792c7f1

commit r11-9828-g556d061e62ea863c7f99129219ca69bf0792c7f1
Author: Jason Merrill <jason@redhat.com>
Date:   Sun Mar 27 22:31:51 2022 -0400

    c++: elaborated-type-spec in requires-expr [PR101677]

    We were failing to declare class S in the global namespace because we were
    treating the requires-expression parameter scope as a normal block scope,
so
    the implicit declaration went there.

    It seems to me that the requires parameter scope is more like a function
    parameter scope (not least in the use of the word "parameter"), so let's
    change the scope kind.  But then we need to adjust the prohibition on
    placeholders declaring implicit template parameters.

            PR c++/101677

    gcc/cp/ChangeLog:

            * name-lookup.h (struct cp_binding_level): Add requires_expression
            bit-field.
            * parser.c (cp_parser_requires_expression): Set it.
            (synthesize_implicit_template_parm): Check it.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-pr67178.C: Adjust error.
            * g++.dg/cpp2a/concepts-requires28.C: New test.

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

* [Bug c++/101677] [11 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward
  2021-07-29 15:58 [Bug c++/101677] New: [11 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward joeloser93 at gmail dot com
                   ` (6 preceding siblings ...)
  2022-04-12 20:14 ` [Bug c++/101677] [11 " cvs-commit at gcc dot gnu.org
@ 2022-04-12 20:22 ` jason at gcc dot gnu.org
  2023-06-09 14:36 ` ppalka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2022-04-12 20:22 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 11.3/12.

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

* [Bug c++/101677] [11 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward
  2021-07-29 15:58 [Bug c++/101677] New: [11 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward joeloser93 at gmail dot com
                   ` (7 preceding siblings ...)
  2022-04-12 20:22 ` jason at gcc dot gnu.org
@ 2023-06-09 14:36 ` ppalka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-06-09 14:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |arthur.j.odwyer at gmail dot com

--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 97988 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2023-06-09 14:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29 15:58 [Bug c++/101677] New: [11 Regression] Concept with use of incomplete type succeeds on GCC 10.3.0, fails on GCC 11 onward joeloser93 at gmail dot com
2021-07-30  6:13 ` [Bug c++/101677] [11/12 " rguenth at gcc dot gnu.org
2021-07-30  6:25 ` pinskia at gcc dot gnu.org
2021-07-30 15:50 ` joeloser93 at gmail dot com
2022-01-17 13:59 ` rguenth at gcc dot gnu.org
2022-04-01 19:30 ` jason at gcc dot gnu.org
2022-04-05 16:29 ` cvs-commit at gcc dot gnu.org
2022-04-12 20:14 ` [Bug c++/101677] [11 " cvs-commit at gcc dot gnu.org
2022-04-12 20:22 ` jason at gcc dot gnu.org
2023-06-09 14:36 ` 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).