When having this code compiling with -Warray-bounds
. I get a warning when declaring array2 array index 3 is past the end of the array (which contains 3 elements)
. But not when declaring array1 even though it has to be the same type thus carrying the same size information. Is this a bug in clang?
enum class Format : int {
Off = 55,
FormatA = 66,
FormatB = 77,
};
inline Format (&AllFormats())[3] {
static Format values[] = {
Format::Off,
Format::FormatA,
Format::FormatB
};
return values;
}
int main()
{
auto array1 = AllFormats();
auto v3 = array1[3];
Format (&array2)[3] = AllFormats();
v3 = array2[3];
}