public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "carlosgalvezp at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/109669] New: Internal Compiler Error when zero-initializing std::array
Date: Fri, 28 Apr 2023 14:08:37 +0000	[thread overview]
Message-ID: <bug-109669-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 109669
           Summary: Internal Compiler Error when zero-initializing
                    std::array
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: carlosgalvezp at gmail dot com
  Target Milestone: ---

Hi,

We are getting an ICE when bumping from
6910cad55ffc330dc9767d2c8e0b66ccfa4134af to
cc035c5d8672f87dc8c2756d9f8367903aa72d93 (GCC 13.1.0 release) on the following
reduced example:

#include <array>

template <typename T, std::size_t n>
struct Point
{
 private:
    T value_[n]{};
};

struct Edge
{
    Point<float, 3> start{};
    Point<float, 3> end{};
};

template <typename T, std::size_t n>
class StaticVector
{
 public:
    static StaticVector create()
    {
        StaticVector output;
        return output;
    }

 private:
    std::array<T, n> data{};
};

class Polygon
{
 public:
    using Edges = StaticVector<Edge, 3>;
    Edges edges() const
    {
        auto edges = Edges::create();
        return edges;
    }
};

void foo()
{
    Polygon polygon{};
    auto const edges = polygon.edges();
}

Godbolt: https://godbolt.org/z/183zv1xrK

Error:
<source>: In instantiation of 'constexpr StaticVector<Edge,
3>::StaticVector()':
<source>:22:22:   required from 'static StaticVector<T, n> StaticVector<T,
n>::create() [with T = Edge; long unsigned int n = 3]'
<source>:36:35:   required from here
<source>:27:22: internal compiler error: Segmentation fault
   27 |     std::array<T, n> data{};
      |                      ^~~~
0x234da0e internal_error(char const*, ...)
        ???:0
0xccea48 finish_for_cond(tree_node*, tree_node*, bool, unsigned short)
        ???:0
0xb7bad3 build_vec_init(tree_node*, tree_node*, tree_node*, bool, int, int,
vec<tree_node*, va_gc, vl_embed>**)
        ???:0
0xce5cfb expand_vec_init_expr(tree_node*, tree_node*, int, vec<tree_node*,
va_gc, vl_embed>**)
        ???:0
0xd200c1 digest_nsdmi_init(tree_node*, tree_node*, int)
        ???:0
0xb813b7 maybe_instantiate_nsdmi_init(tree_node*, int)
        ???:0
0xb819f9 get_nsdmi(tree_node*, bool, int)
        ???:0
0xba932d get_defaulted_eh_spec(tree_node*, int)
        ???:0
0xc76d4a maybe_instantiate_noexcept(tree_node*, int)
        ???:0
0xc76b5a maybe_instantiate_noexcept(tree_node*, int)
        ???:0
0xb5c2b3 mark_used(tree_node*, int)
        ???:0
0xa9931e build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
        ???:0
0xa9a4c7 build_special_member_call(tree_node*, tree_node*, vec<tree_node*,
va_gc, vl_embed>**, tree_node*, int, int)
        ???:0
0xb7d468 build_aggr_init(tree_node*, tree_node*, int, int)
        ???:0
0xb4c768 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ???:0
0xc80395 instantiate_decl(tree_node*, bool, bool)
        ???:0
0xcab7fb instantiate_pending_templates(int)
        ???:0
0xb5f735 c_parse_final_cleanups()
        ???:0
0xd8f918 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1

I tried to reduce it with creduce but creduce itself crashed :/

             reply	other threads:[~2023-04-28 14:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-28 14:08 carlosgalvezp at gmail dot com [this message]
2023-04-28 14:20 ` [Bug c++/109669] " 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-109669-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).