[Bug c/109828] C2x:static compound literal (with flexible array) in initializer leads to invalid size and ICE

2023-05-12 Thread yann at droneaud dot fr via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109828

--- Comment #2 from Yann Droneaud  ---
(In reply to Yann Droneaud from comment #0)
> The following code is badly compiled by GCC 13.1:
> 
> struct s { int i; char c[]; };
> 
> const struct s s = { .c = "0", };
> const struct s *r = &(constexpr struct s) { .c = "1", };
> const struct s *t = &(static struct s) { .c = "2", };
> 
> Targetting x86-64 / amd64, compiling this with gcc -std=gnu2x -S, produces
> surprising large .zero directive:
> 
> s: 
> .zero   4
> .string "0"
> __compound_literal.0:
> .zero   4
> .string "1"
> .zero   18446744073709551613
> .zero   1
> r:
> .quad   __compound_literal.0
> __compound_literal.1:
> .zero   4
> .string "2"
> .zero   18446744073709551613
> .zero   1
> t:
> .quad   __compound_literal.1
> 
>

When asked to assemble that, binutils' as complains:

$ gcc -std=gnu2x nice.c -c
/tmp/ccZEWv73.s: Assembler messages:
/tmp/ccZEWv73.s:17: Warning: .space repeat count is zero, ignored
/tmp/ccZEWv73.s:32: Warning: .space repeat count is zero, ignored

[Bug c/109828] C2x:static compound literal (with flexible array) in initializer leads to invalid size and ICE

2023-05-12 Thread yann at droneaud dot fr via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109828

Yann Droneaud  changed:

   What|Removed |Added

 CC||yann at droneaud dot fr

--- Comment #1 from Yann Droneaud  ---
I should mention GCC trunk (gcc 14.0.0 20230510 on godbolt.org) is experiencing
ICE without the need to call __builtin_object_size().