3 ms·
This is undefined behaviour except when using msvc. For GCC and clang, you should use [] (empty square brackets) to denote a variable length array at the end of
by Asooka 6y ago
This is undefined behaviour except when using msvc. For GCC and clang, you should use [] (empty square brackets) to denote a variable length array at the end of a struct. For msvc, [1] is used all over win32 and is explicitly supported for that purpose.
Edit: it's UB because you're accessing past the end of an array with size given at compile time.
- kevin_thibedeau 6y ago[] syntax in the last struct member is a "flexible array member" not a VLA. The former hasn't been deprecated in C11.