On 2020/8/3 12:24 AM, Thomas Koenig via Gcc wrote:
Hi,
in a patch I am developing, I have the following code:
typedef struct {
gfc_code *c;
int branch_level;
bool seen_goto;
vec <gfc_expr *> extrema;
} do_t;
static vec<do_t> doloop_list;
[...]
do_t loop;
doloop_list.safe_push (loop);
doloop_list.last().extrema.reserve (1 << doloop_level);
where the last statement segfaults. It also segfaults if
I replace the last line with
doloop_list[0].extrema.reserve (1 << doloop_level);
Is there something glaringly obvious I am doing wrong, and
could this be easily fixed?
I think you need to initialize the 'vec<gfc_expr *> extrema' field with vNULL,
or maybe some other constructor.
Chung-Lin
If not, I guess I'll just implement this using standard C
techniques (i.e. malloc/realloc). It will look a bit strange,
but, as a wise man once said, a patch that works beats
an elegant idea every time...
Best regards
Thomas