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

--- Comment #20 from Richard Biener <rguenth at gcc dot gnu.org> ---
It might be possible to use C++ to hide awkwardness of dynamic allocation and
still support a cheap stack-based allocation for small -fmax-identifier-length.

You can use

auto_vec<char, 63> buf;
buf.reserve_exact (max_identifier_length);

char *the_buf = &buf[0];

for example, but of course I'd simply add a wrapping

class gfc_symbol_buffer
{
...
};

so you can instead do

gfc_symbol_buffer the_buf;

and have it behave like a char the_buf[GFC_MAX_SYMBOL_LEN] declaration.

The auto_vec sequence above uses a stack allocation for up to 63 length
and otherwise a heap allocation (and makes sure to free the allocation
when the buffer goes out of scope).

Reply via email to