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

            Bug ID: 120668
           Summary: ICE: Segmentation fault with invalid array size inside
                    template function
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rush102333 at gmail dot com
  Target Milestone: ---

Simplified test:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

template<typename T>
void
test_callnew()
{
  new int[0.2];
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Stack Dump:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<source>: In function 'void test_callnew()':
<source>:5:11: error: size in array new must have integral type
[-Wtemplate-body]
    5 |   new int[0.2];
      |           ^~~
<source>:5:14: internal compiler error: in tsubst_expr, at cp/pt.cc:21001
    5 |   new int[0.2];
      |              ^
0x2833015 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x28547a6 internal_error(char const*, ...)
        ???:0
0xae00bc fancy_abort(char const*, int, char const*)
        ???:0
0xc12d40 build_new(unsigned long, vec<tree_node*, va_gc, vl_embed>**,
tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, int, int)
        ???:0
0xd05f53 c_parse_file()
        ???:0
0xe6db59 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.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Please see https://godbolt.org/z/Pxnnj1TEb

Reply via email to