public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109669] New: Internal Compiler Error when zero-initializing std::array
@ 2023-04-28 14:08 carlosgalvezp at gmail dot com
  2023-04-28 14:20 ` [Bug c++/109669] " mpolacek at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: carlosgalvezp at gmail dot com @ 2023-04-28 14:08 UTC (permalink / raw)
  To: gcc-bugs

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 :/

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

* [Bug c++/109669] Internal Compiler Error when zero-initializing std::array
  2023-04-28 14:08 [Bug c++/109669] New: Internal Compiler Error when zero-initializing std::array carlosgalvezp at gmail dot com
@ 2023-04-28 14:20 ` mpolacek at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-04-28 14:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE
                 CC|                            |mpolacek at gcc dot gnu.org

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

commit 041a164ec9b467f9ac2f15980f83f17e3f8ea150
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Mar 18 08:27:26 2023 -0400

    c++: DMI in template with virtual base [PR106890]

so I think it's a dup.

*** This bug has been marked as a duplicate of bug 109666 ***

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

end of thread, other threads:[~2023-04-28 14:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-28 14:08 [Bug c++/109669] New: Internal Compiler Error when zero-initializing std::array carlosgalvezp at gmail dot com
2023-04-28 14:20 ` [Bug c++/109669] " mpolacek 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).