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

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Clang seems to use SIZE_MAX / 8 as the maximum object size and gives an error
for any object whose size exceeds that.  But it doesn't seem to doesn't track
total object sizes and crashes in LLVM as it runs out of memory for the test
case below:

#include <stdint.h>

char a[SIZE_MAX / 8] = "1";
char b[SIZE_MAX / 8] = "x";

In C mode, GCC compiles the code above without hanging anywhere but G++ gives
errors.  In fact, it fails with the same error even for 'char a[INT_MAX >> 2] =
"1";'

a.c:3:24: error: initializer-string for array of chars is too long
[-fpermissive]
    3 | char a[SIZE_MAX / 8] = "1";
      |                        ^~~
a.c:4:24: error: initializer-string for array of chars is too long
[-fpermissive]
    4 | char b[SIZE_MAX / 8] = "x";
      |                        ^~~

Reply via email to