public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103408] New: ICE when requires auto(x) in C++23
@ 2021-11-24 16:20 hewillk at gmail dot com
  2021-11-24 16:23 ` [Bug c++/103408] " mpolacek at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: hewillk at gmail dot com @ 2021-11-24 16:20 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103408
           Summary: ICE when requires auto(x) in C++23
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

auto f() requires (auto(0));

https://godbolt.org/z/baEr7nqbW

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

* [Bug c++/103408] ICE when requires auto(x) in C++23
  2021-11-24 16:20 [Bug c++/103408] New: ICE when requires auto(x) in C++23 hewillk at gmail dot com
@ 2021-11-24 16:23 ` mpolacek at gcc dot gnu.org
  2021-11-24 16:24 ` mpolacek at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-11-24 16:23 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |mpolacek at gcc dot gnu.org
   Last reconfirmed|                            |2021-11-24
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/103408] ICE when requires auto(x) in C++23
  2021-11-24 16:20 [Bug c++/103408] New: ICE when requires auto(x) in C++23 hewillk at gmail dot com
  2021-11-24 16:23 ` [Bug c++/103408] " mpolacek at gcc dot gnu.org
@ 2021-11-24 16:24 ` mpolacek at gcc dot gnu.org
  2021-11-25 13:38 ` hewillk at gmail dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-11-24 16:24 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r12-5386, obviously.

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

* [Bug c++/103408] ICE when requires auto(x) in C++23
  2021-11-24 16:20 [Bug c++/103408] New: ICE when requires auto(x) in C++23 hewillk at gmail dot com
  2021-11-24 16:23 ` [Bug c++/103408] " mpolacek at gcc dot gnu.org
  2021-11-24 16:24 ` mpolacek at gcc dot gnu.org
@ 2021-11-25 13:38 ` hewillk at gmail dot com
  2021-11-30 21:22 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: hewillk at gmail dot com @ 2021-11-25 13:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to Marek Polacek from comment #2)
> Started with r12-5386, obviously.

I don't know if it is caused by the same bug.

template<auto>
concept C = auto([]{});
static_assert(C<0>);

https://godbolt.org/z/nj6qbGxP7

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

* [Bug c++/103408] ICE when requires auto(x) in C++23
  2021-11-24 16:20 [Bug c++/103408] New: ICE when requires auto(x) in C++23 hewillk at gmail dot com
                   ` (2 preceding siblings ...)
  2021-11-25 13:38 ` hewillk at gmail dot com
@ 2021-11-30 21:22 ` mpolacek at gcc dot gnu.org
  2021-12-02 13:12 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-11-30 21:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to 康桓瑋 from comment #3)
> (In reply to Marek Polacek from comment #2)
> > Started with r12-5386, obviously.
> 
> I don't know if it is caused by the same bug.
> 
> template<auto>
> concept C = auto([]{});
> static_assert(C<0>);
> 
> https://godbolt.org/z/nj6qbGxP7

That's a different bug, but I think I can fix that too.

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

* [Bug c++/103408] ICE when requires auto(x) in C++23
  2021-11-24 16:20 [Bug c++/103408] New: ICE when requires auto(x) in C++23 hewillk at gmail dot com
                   ` (3 preceding siblings ...)
  2021-11-30 21:22 ` mpolacek at gcc dot gnu.org
@ 2021-12-02 13:12 ` cvs-commit at gcc dot gnu.org
  2021-12-06 13:59 ` ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-02 13:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:6f43a8a08053a871e785e2ebc80383e0849efb6f

commit r12-5710-g6f43a8a08053a871e785e2ebc80383e0849efb6f
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Nov 30 16:43:19 2021 -0500

    c++: ICE with unnamed tparm and concept [PR103408]

    Here we crash when issuing the "constraint C has type T, not bool"
    error, because pp_cxx_parameter_mapping wasn't prepared to see an
    anonymous template parameter.  With this patch we print

    error: constraint 'auto(<lambda>) [with <unnamed> = 0]' has type
'<lambda()>', not 'bool'

    The "<unnamed>" is what this patch adds.

            PR c++/103408

    gcc/cp/ChangeLog:

            * cxx-pretty-print.c (pp_cxx_parameter_mapping): Print "<unnamed>"
            rather than crash on an unnamed template parameter.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp23/concepts-err1.C: New test.

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

* [Bug c++/103408] ICE when requires auto(x) in C++23
  2021-11-24 16:20 [Bug c++/103408] New: ICE when requires auto(x) in C++23 hewillk at gmail dot com
                   ` (4 preceding siblings ...)
  2021-12-02 13:12 ` cvs-commit at gcc dot gnu.org
@ 2021-12-06 13:59 ` ppalka at gcc dot gnu.org
  2021-12-14 13:16 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-12-06 13:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cooky.ykooc922 at gmail dot com

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

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

* [Bug c++/103408] ICE when requires auto(x) in C++23
  2021-11-24 16:20 [Bug c++/103408] New: ICE when requires auto(x) in C++23 hewillk at gmail dot com
                   ` (5 preceding siblings ...)
  2021-12-06 13:59 ` ppalka at gcc dot gnu.org
@ 2021-12-14 13:16 ` cvs-commit at gcc dot gnu.org
  2021-12-15 10:20 ` cvs-commit at gcc dot gnu.org
  2021-12-15 20:04 ` ppalka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-14 13:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:561414cdf8ef0d3c1e2da80b3c8aae56de745b1e

commit r12-5952-g561414cdf8ef0d3c1e2da80b3c8aae56de745b1e
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Dec 14 08:15:52 2021 -0500

    c++: processing_template_decl vs template depth [PR103408]

    We use processing_template_decl in two slightly different ways: as a
    flag to signal that we're dealing with templated trees, and as a measure
    of the current syntactic template nesting depth.  This overloaded
    meaning of p_t_d is conceptually confusing and leads to bugs that we end
    up working around in an ad-hoc fashion.

    This patch replaces all uses of processing_template_decl that care about
    its magnitude to instead look at the depth of current_template_parms
    via a new macro current_template_depth.  This allows us to eliminate 3
    workarounds in the concepts code: two about non-templated
    requires-expressions (in constraint.cc) and one about lambdas inside
    constraints (in cp_parser_requires_clause_expression etc).  This also
    fixes the testcase in PR103408 about auto(x) used inside a non-templated
    requires-expression.

    The replacement was mostly mechanical, aside from two issues:

      * In synthesize_implicit_template_parm, when introducing a new template
        parameter list for an abbreviated function template, we need to add
        the new level of current_template_parms sooner, before calling
        process_template_parm, since this latter function now looks at
        current_template_depth to determine the level of the new parameter.

      * In instantiate_class_template_1 after substituting a template
        friend declaration, we currently increment processing_template_decl
        around the call to make_friend_class so that the friend_depth
        computation within this subroutine yields a nonzero value.  We could
        just replace this with an equivalent manipulation of
        current_template_depth, but this patch instead rewrites the
        friend_depth calculation within make_friend_class to not depend on
        p_t_d / c_t_d at all when called from instantiate_class_template_1.

            PR c++/103408

    gcc/cp/ChangeLog:

            * constraint.cc (type_deducible_p): Remove workaround for
            non-templated requires-expressions.
            (normalize_placeholder_type_constraints): Likewise.
            * cp-tree.h (current_template_depth): Define.
            (PROCESSING_REAL_TEMPLATE_DECL): Inspect current_template_depth
            instead of the magnitude of processing_template_decl.
            * decl.c (start_decl): Likewise.
            (grokfndecl): Likewise.
            (grokvardecl): Likewise.
            (grokdeclarator): Likewise.
            * friend.c (make_friend_class): Likewise.  Calculate
            friend_depth differently when called at instantiation time
            instead of parse time.
            (do_friend): Likewise.
            * parser.c (cp_parser_requires_clause_expression): Remove
            workaround for lambdas inside constraints.
            (cp_parser_constraint_expression): Likewise.
            (cp_parser_requires_expression): Likewise.
            (synthesize_implicit_template_parm): Add to current_template_parms
            before calling process_template_parm.
            * pt.c (inline_needs_template_parms): Inspect
            current_template_depth instead of the magnitude of
            processing_template_decl.
            (push_inline_template_parms_recursive): Likewise.
            (maybe_begin_member_template_processing): Likewise.
            (begin_template_parm_list): Likewise.
            (process_template_parm): Likewise.
            (end_template_parm_list): Likewise.
            (push_template_decl): Likewise.
            (add_inherited_template_parms): Likewise.
            (instantiate_class_template_1): Don't adjust
            processing_template_decl around the call to make_friend_class.
            adjust_processing_template_decl to adjust_template_depth.  Set
            current_template_parms instead of processing_template_decl when
            adjust_template_depth.
            (make_auto_1): Inspect current_template_depth instead of the
            magnitude of processing_template_decl.
            (splice_late_return_type): Likewise.
            * semantics.c (fixup_template_type): Likewise.

    gcc/testsuite/ChangeLog:

            * g++.dg/concepts/diagnostic18.C: Expect a "constraints on a
            non-templated function" error.
            * g++.dg/cpp23/auto-fncast11.C: New test.

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

* [Bug c++/103408] ICE when requires auto(x) in C++23
  2021-11-24 16:20 [Bug c++/103408] New: ICE when requires auto(x) in C++23 hewillk at gmail dot com
                   ` (6 preceding siblings ...)
  2021-12-14 13:16 ` cvs-commit at gcc dot gnu.org
@ 2021-12-15 10:20 ` cvs-commit at gcc dot gnu.org
  2021-12-15 20:04 ` ppalka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-15 10:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:6bf5d9108ae2dcb6cb883442d7bd299fd8fc15e9

commit r12-5995-g6bf5d9108ae2dcb6cb883442d7bd299fd8fc15e9
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Dec 15 11:18:14 2021 +0100

    testsuite: Fix up cpp23/auto-fncast11.C testcase [PR103408]

    This test fails:
    +FAIL: g++.dg/cpp23/auto-fncast11.C  -std=c++2b  (test for errors, line 19)
    +FAIL: g++.dg/cpp23/auto-fncast11.C  -std=c++2b (test for excess errors)
    because the regex in dg-error was missing an indefinite article.

    2021-12-15  Jakub Jelinek  <jakub@redhat.com>

            PR c++/103408
            * g++.dg/cpp23/auto-fncast11.C: Fix expected diagnostic wording.

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

* [Bug c++/103408] ICE when requires auto(x) in C++23
  2021-11-24 16:20 [Bug c++/103408] New: ICE when requires auto(x) in C++23 hewillk at gmail dot com
                   ` (7 preceding siblings ...)
  2021-12-15 10:20 ` cvs-commit at gcc dot gnu.org
@ 2021-12-15 20:04 ` ppalka at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-12-15 20:04 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #9 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12.

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

end of thread, other threads:[~2021-12-15 20:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24 16:20 [Bug c++/103408] New: ICE when requires auto(x) in C++23 hewillk at gmail dot com
2021-11-24 16:23 ` [Bug c++/103408] " mpolacek at gcc dot gnu.org
2021-11-24 16:24 ` mpolacek at gcc dot gnu.org
2021-11-25 13:38 ` hewillk at gmail dot com
2021-11-30 21:22 ` mpolacek at gcc dot gnu.org
2021-12-02 13:12 ` cvs-commit at gcc dot gnu.org
2021-12-06 13:59 ` ppalka at gcc dot gnu.org
2021-12-14 13:16 ` cvs-commit at gcc dot gnu.org
2021-12-15 10:20 ` cvs-commit at gcc dot gnu.org
2021-12-15 20:04 ` 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).