[Bug c++/65966] "sorry, unimplemented: unexpected AST of kind try_block" when initializing a 2D array

lhyatt at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed May 6 20:14:00 GMT 2015


--- Comment #1 from Lewis Hyatt <lhyatt at gmail dot com> ---

I have some additional information that I hope is helpful to look into this.

A. Regarding the first testcase, a regression from 4.9, which produces the
"sorry, unimplemented" error in 5.1:

1. I forgot to mention explicitly, this does require -std=c++14; with
-std=c++11 it works fine.

2. The issue started at the following revision:

Author: jason
Date: Mon Feb  9 19:15:55 2015
New Revision: 220544

URL: https://gcc.gnu.org/viewcvs?rev=220544&root=gcc&view=rev
        PR c++/64899
        * init.c (build_vec_init): Handle default-initialized array with
        constexpr default constructor.


B. Regarding the second testcase, which compiles in 5.1, but produces
unexpected output (for an array of N elements total, there are N calls to the
constructor output in the code, no matter how large N may be):

This seems to be an unrelated issue. It did not start failing at the above
revision, rather it ICEs in that revision and the few prior to it that I
checked. It also happens whether you have -std=c++11 or -std=c++14, and I see
the same behavior in gcc 4.7, 4.8 and 4.9 as well (in those releases, it works,
does not ICE, but does output the huge number of instructions). So it seems
that over time, it has changed several times whether it ICEs or compiles, but
it has always generated this unexpected code.

Should I file this as a separate bug? It seems like it must not be intentional,
as it basically makes it impossible to brace-initialize large arrays (e.g. in
an object that is meant to be allocated dynamically, where the stack size is
not an issue, one might reasonably use an array with very many elements and not
expect the code size to be O(N) for N elements). Here is a simplified testcase,
it doesn't depend on NSDMI, just on brace initialization, and it's the same for
even 1D arrays:

struct A {

#define N 10000
struct B {
    A array[N];
    B() : array{} {}
} b;

And the issue is that this has had O(N) compile time and O(N) code size, since,
as far as I can tell, brace initialization was ever supported. Changing array{}
to array() works fine, as does omitting the initializer entirely.



More information about the Gcc-bugs mailing list