public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101764] New: ICE for constexpr if within fold expression within lambda expression within a template
@ 2021-08-03 18:57 johelegp at gmail dot com
  2021-08-13 19:39 ` [Bug c++/101764] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: johelegp at gmail dot com @ 2021-08-03 18:57 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101764
           Summary: ICE for constexpr if within fold expression within
                    lambda expression within a template
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: johelegp at gmail dot com
                CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/o944oWafx.
```C++
void f(auto i) {
  ([]<class... T>(T...) {
    return (..., [] {
      if constexpr (T{0})
        ;
    }());
  }(i));
}
void g() { f(0); }
```
```
<source>: In instantiation of 'f<int>(int)::<lambda(T ...)> [with T = {int}]':
<source>:7:4:   required from 'void f(auto:1) [with auto:1 = int]'
<source>:9:13:   required from here
<source>:6:8: internal compiler error: in tsubst_pack_expansion, at
cp/pt.c:13102
    6 |     }());
      |        ^
0x1dadf09 internal_error(char const*, ...)
        ???:0
0x6e5511 fancy_abort(char const*, int, char const*)
        ???:0
0x962157 tsubst_pack_expansion(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x94de47 instantiate_decl(tree_node*, bool, bool)
        ???:0
0x7f5dbe maybe_instantiate_decl(tree_node*)
        ???:0
0x7f7520 mark_used(tree_node*, int)
        ???:0
0x710ad5 build_op_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
        ???:0
0x9b4935 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ???:0
0x94de47 instantiate_decl(tree_node*, bool, bool)
        ???:0
0x99020b instantiate_pending_templates(int)
        ???:0
0x7fb2f9 c_parse_final_cleanups()
        ???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```

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

* [Bug c++/101764] ICE for constexpr if within fold expression within lambda expression within a template
  2021-08-03 18:57 [Bug c++/101764] New: ICE for constexpr if within fold expression within lambda expression within a template johelegp at gmail dot com
@ 2021-08-13 19:39 ` pinskia at gcc dot gnu.org
  2021-08-20 13:50 ` ppalka at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-13 19:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-08-13
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/101764] ICE for constexpr if within fold expression within lambda expression within a template
  2021-08-03 18:57 [Bug c++/101764] New: ICE for constexpr if within fold expression within lambda expression within a template johelegp at gmail dot com
  2021-08-13 19:39 ` [Bug c++/101764] " pinskia at gcc dot gnu.org
@ 2021-08-20 13:50 ` ppalka at gcc dot gnu.org
  2021-09-13 14:31 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-08-20 13:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug c++/101764] ICE for constexpr if within fold expression within lambda expression within a template
  2021-08-03 18:57 [Bug c++/101764] New: ICE for constexpr if within fold expression within lambda expression within a template johelegp at gmail dot com
  2021-08-13 19:39 ` [Bug c++/101764] " pinskia at gcc dot gnu.org
  2021-08-20 13:50 ` ppalka at gcc dot gnu.org
@ 2021-09-13 14:31 ` cvs-commit at gcc dot gnu.org
  2021-09-13 14:59 ` ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-09-13 14:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 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:c8b2b89358481d36755dbc99e585a251780453b0

commit r12-3488-gc8b2b89358481d36755dbc99e585a251780453b0
Author: Patrick Palka <ppalka@redhat.com>
Date:   Mon Sep 13 10:29:32 2021 -0400

    c++: parameter pack inside constexpr if [PR101764]

    Here when partially instantiating the first pack expansion, substitution
    into the condition of the constexpr if yields a still-dependent tree, so
    tsubst_expr returns an IF_STMT with an unsubstituted IF_COND and with
    IF_STMT_EXTRA_ARGS added to.  Hence after partial instantiation the pack
    expansion pattern still refers to the unlowered parameter pack 'ts' of
    level 2, and it's thusly recorded in the new
PACK_EXPANSION_PARAMETER_PACKS.
    During the subsequent final instantiation of the regenerated lambda we
    crash in tsubst_pack_expansion because it can't find an argument pack
    for this unlowered 'ts', due to the level mismatch.  (Likewise when the
    constexpr if is replaced by a requires-expr, which also uses the extra
    args mechanism for avoiding partial instantiation.)

    So essentially, a pack expansion pattern that contains an "extra args"
    tree doesn't play well with partial instantiation.  This patch fixes
    this by forcing such pack expansions to use the extra args mechanism as
    well.

            PR c++/101764

    gcc/cp/ChangeLog:

            * cp-tree.h (PACK_EXPANSION_FORCE_EXTRA_ARGS_P): New accessor
            macro.
            * pt.c (has_extra_args_mechanism_p): New function.
            (find_parameter_pack_data::found_extra_args_tree_p): New data
            member.
            (find_parameter_packs_r): Set ppd->found_extra_args_tree_p
            appropriately.
            (make_pack_expansion): Set PACK_EXPANSION_FORCE_EXTRA_ARGS_P if
            ppd.found_extra_args_tree_p.
            (use_pack_expansion_extra_args_p): Return true if there were
            unsubstituted packs and PACK_EXPANSION_FORCE_EXTRA_ARGS_P.
            (tsubst_pack_expansion): Pass the pack expansion to
            use_pack_expansion_extra_args_p.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/constexpr-if35.C: New test.

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

* [Bug c++/101764] ICE for constexpr if within fold expression within lambda expression within a template
  2021-08-03 18:57 [Bug c++/101764] New: ICE for constexpr if within fold expression within lambda expression within a template johelegp at gmail dot com
                   ` (2 preceding siblings ...)
  2021-09-13 14:31 ` cvs-commit at gcc dot gnu.org
@ 2021-09-13 14:59 ` ppalka at gcc dot gnu.org
  2021-10-03  1:26 ` ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-09-13 14:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

* [Bug c++/101764] ICE for constexpr if within fold expression within lambda expression within a template
  2021-08-03 18:57 [Bug c++/101764] New: ICE for constexpr if within fold expression within lambda expression within a template johelegp at gmail dot com
                   ` (3 preceding siblings ...)
  2021-09-13 14:59 ` ppalka at gcc dot gnu.org
@ 2021-10-03  1:26 ` ppalka at gcc dot gnu.org
  2021-11-02 19:56 ` ppalka at gcc dot gnu.org
  2022-10-18 23:26 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-10-03  1:26 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hewillk at gmail dot com

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

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

* [Bug c++/101764] ICE for constexpr if within fold expression within lambda expression within a template
  2021-08-03 18:57 [Bug c++/101764] New: ICE for constexpr if within fold expression within lambda expression within a template johelegp at gmail dot com
                   ` (4 preceding siblings ...)
  2021-10-03  1:26 ` ppalka at gcc dot gnu.org
@ 2021-11-02 19:56 ` ppalka at gcc dot gnu.org
  2022-10-18 23:26 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-11-02 19:56 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |c.de-claverie at pm dot me

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

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

* [Bug c++/101764] ICE for constexpr if within fold expression within lambda expression within a template
  2021-08-03 18:57 [Bug c++/101764] New: ICE for constexpr if within fold expression within lambda expression within a template johelegp at gmail dot com
                   ` (5 preceding siblings ...)
  2021-11-02 19:56 ` ppalka at gcc dot gnu.org
@ 2022-10-18 23:26 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-10-18 23:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Joseph Myers <jsm28@gcc.gnu.org>:

https://gcc.gnu.org/g:f5f1d92fe2e1d75c3fae34497929a1965af704ae

commit r13-3366-gf5f1d92fe2e1d75c3fae34497929a1965af704ae
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Tue Oct 18 23:25:47 2022 +0000

    c: Diagnose "enum tag;" after definition [PR107164]

    As noted in bug 101764, a declaration "enum tag;" is invalid in
    standard C after a definition, as well as when no definition is
    visible; we had a pedwarn-if-pedantic for the forward declaration
    case, but were missing one for the other case.  Add that missing
    diagnostic (if pedantic only).

    (These diagnostics will need to be appropriately conditioned when
    support is added for C2x enums with fixed underlying type, since "enum
    tag : type;" is OK both before and after a definition.)

    Bootstrapped with no regressions for x86_64-pc-linux-gnu.

            PR c/107164

    gcc/c/
            * c-decl.cc (shadow_tag_warned): If pedantic, diagnose "enum tag;"
            with previous declaration visible.

    gcc/testsuite/
            * gcc.dg/c99-tag-4.c, gcc.dg/c99-tag-5.c, gcc.dg/c99-tag-6.c: New
            tests.

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

end of thread, other threads:[~2022-10-18 23:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03 18:57 [Bug c++/101764] New: ICE for constexpr if within fold expression within lambda expression within a template johelegp at gmail dot com
2021-08-13 19:39 ` [Bug c++/101764] " pinskia at gcc dot gnu.org
2021-08-20 13:50 ` ppalka at gcc dot gnu.org
2021-09-13 14:31 ` cvs-commit at gcc dot gnu.org
2021-09-13 14:59 ` ppalka at gcc dot gnu.org
2021-10-03  1:26 ` ppalka at gcc dot gnu.org
2021-11-02 19:56 ` ppalka at gcc dot gnu.org
2022-10-18 23:26 ` cvs-commit 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).