public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pieter.p.dev at outlook dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/116015] New: ICE in replace_placeholders_r for simple default member initializer
Date: Sat, 20 Jul 2024 15:37:52 +0000	[thread overview]
Message-ID: <bug-116015-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 116015
           Summary: ICE in replace_placeholders_r for simple default
                    member initializer
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pieter.p.dev at outlook dot com
  Target Milestone: ---

Created attachment 58713
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58713&action=edit
Output from -freport-bug

G++ crashes when using member variables in the default initializer for another
member. Minimal example:

    struct MatrixLayout {
        int rows         = 0;
        int outer_stride = rows;
    };
    struct Matrix {
        Matrix(MatrixLayout) {}
    };
    struct Widget {
        int n = 5;
        Matrix A{{.rows = n}};
    };
    int main() {
        Widget w{};
    }

All versions of GCC between at least 5.1 and 14.1 seem to be affected:
  - 5.1: https://godbolt.org/z/1PKx8djxG
  - 14.1: https://godbolt.org/z/1eeEcYoqd
  - trunk: https://godbolt.org/z/7j7n38ohh
(8d6498f0d772775ad09d7d9e14f491a306e5f853)

Possibly related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100252#c5.

To the best of my knowledge, the source code is valid C++20 (and valid C++11
without the designated initializer), and Clang and MSVC compile the same code
without issues.

Output from GCC 14.1:

    ice.cpp: In function 'int main()':
    ice.cpp:16:14: internal compiler error: in replace_placeholders_r, at
cp/tree.cc:3414
       16 |     Widget w{};
          |              ^
    0x732cae replace_placeholders_r
        cp/tree.cc:3414
    0x11be9e3 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*,
void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        tree.cc:11429
    0x11bef2f walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*,
void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        tree.cc:11663
    0x960b0c replace_placeholders_r
        cp/tree.cc:3459
    0x11be9e3 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*,
void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        tree.cc:11429
    0x95d985 replace_placeholders(tree_node*, tree_node*, bool*)
        cp/tree.cc:3497
    0x7e0dde cp_gimplify_init_expr
        cp/cp-gimplify.cc:339
    0x7e0dde cp_gimplify_expr(tree_node**, gimple**, gimple**)
        cp/cp-gimplify.cc:652
    0xc139b8 gimplify_expr(tree_node**, gimple**, gimple**, bool
(*)(tree_node*), int)
        gimplify.cc:17790
    0xc17616 gimplify_stmt(tree_node**, gimple**)
        gimplify.cc:7578
    0xc19632 gimplify_and_add(tree_node*, gimple**)
        gimplify.cc:515
    0xc19632 internal_get_tmp_var
        gimplify.cc:674
    0xc13c7b gimplify_expr(tree_node**, gimple**, gimple**, bool
(*)(tree_node*), int)
        gimplify.cc:18908
    0xc1b564 gimplify_expr
        gimplify.cc:18953
    0xc1b564 gimplify_arg(tree_node**, gimple**, unsigned int, bool)
        gimplify.cc:3779
    0xc1da17 gimplify_call_expr
        gimplify.cc:4064
    0xc15ac2 gimplify_expr(tree_node**, gimple**, gimple**, bool
(*)(tree_node*), int)
        gimplify.cc:17853
    0xc17616 gimplify_stmt(tree_node**, gimple**)
        gimplify.cc:7578
    0xc15607 gimplify_cleanup_point_expr
        gimplify.cc:7316
    0xc15607 gimplify_expr(tree_node**, gimple**, gimple**, bool
(*)(tree_node*), int)
        gimplify.cc:18277

             reply	other threads:[~2024-07-20 15:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-20 15:37 pieter.p.dev at outlook dot com [this message]
2024-07-20 17:42 ` [Bug c++/116015] " mpolacek at gcc dot gnu.org
2024-07-20 17:42 ` mpolacek at gcc dot gnu.org
2024-07-21 15:00 ` pieter.p.dev at outlook dot com
2024-08-01 13:51 ` ppalka at gcc dot gnu.org
2024-08-01 14:02 ` mpolacek at gcc dot gnu.org
2024-08-06 18:54 ` mpolacek at gcc dot gnu.org
2024-08-06 19:04 ` mpolacek at gcc dot gnu.org
2024-08-07 21:55 ` mpolacek at gcc dot gnu.org
2024-08-14 19:36 ` cvs-commit at gcc dot gnu.org
2024-08-14 19:37 ` mpolacek 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-116015-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).