Date: Mon, 15 Jun 2020 09:11:30 +0200
Hello everybody,
I'm writing as I'm curious about one accidental discovery, due to bug that
compiles well and works well on gcc.
I declare fixed size array like I used to for years:
int my_array[] = { 0, 1, 2, 3, 4};
then I found code that accidentally allocates size of such array with a
variable that is defined during runtime
int some_size = value_retrieved_from_somewhere_else;
int my_array[some_size];
my_array[3] = 123;
and this code compiles and works well under gcc's c++ even though some_size
is not constexpr.
Obvious bug in the compiler or some feature I'm not aware of?
-
/h1
I'm writing as I'm curious about one accidental discovery, due to bug that
compiles well and works well on gcc.
I declare fixed size array like I used to for years:
int my_array[] = { 0, 1, 2, 3, 4};
then I found code that accidentally allocates size of such array with a
variable that is defined during runtime
int some_size = value_retrieved_from_somewhere_else;
int my_array[some_size];
my_array[3] = 123;
and this code compiles and works well under gcc's c++ even though some_size
is not constexpr.
Obvious bug in the compiler or some feature I'm not aware of?
-
/h1
Received on 2020-06-15 02:14:52