https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126310
Martin Jambor <jamborm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jamborm at gcc dot gnu.org
--- Comment #4 from Martin Jambor <jamborm at gcc dot gnu.org> ---
The code walking the type of the global decl and the static
constructor expects that indices in the constructor match the fields
in the type, using pointer equality, no less. But in this case, that
is not the case and the corresponding element of the constructor is
therefore missed and the code expects the corresponding field is
zero-initialized.
The type of the decl has this field:
<field_decl 0x7ffff75e4820 __delta
type <integer_type 0x7ffff7423738 long int public DI
size <integer_cst 0x7ffff741b300 constant 64>
unit-size <integer_cst 0x7ffff741b318 constant 8>
align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff7423738 precision:64 min <integer_cst 0x7ffff741b588
-9223372036854775808> max <integer_cst 0x7ffff741b5a0 9223372036854775807>
pointer_to_this <pointer_type 0x7ffff7434e70>>
nonaddressable DI pr126310.C:11:39 size <integer_cst 0x7ffff741b300 64>
unit-size <integer_cst 0x7ffff741b318 8>
align:64 warn_if_not_align:0 offset_align 128 decl_not_flexarray: 0
offset <integer_cst 0x7ffff741b330 type <integer_type 0x7ffff7423000
sizetype> constant 0> bit-offset <integer_cst 0x7ffff741b300 64> context
<record_type 0x7ffff75e55e8>>
The field in the constructor element is:
<field_decl 0x7ffff75e4e60 __delta
type <integer_type 0x7ffff7423738 long int public DI
size <integer_cst 0x7ffff741b300 constant 64>
unit-size <integer_cst 0x7ffff741b318 constant 8>
align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff7423738 precision:64 min <integer_cst 0x7ffff741b588
-9223372036854775808> max <integer_cst 0x7ffff741b5a0 9223372036854775807>
pointer_to_this <pointer_type 0x7ffff7434e70>>
nonaddressable DI pr126310.C:16:1 size <integer_cst 0x7ffff741b300 64>
unit-size <integer_cst 0x7ffff741b318 8>
align:64 warn_if_not_align:0 offset_align 128 decl_not_flexarray: 0
offset <integer_cst 0x7ffff741b330 type <integer_type 0x7ffff7423000
sizetype> constant 0> bit-offset <integer_cst 0x7ffff741b300 64> context
<record_type 0x7ffff75ea498>>
The record_type contexts may be bit telling, 0x7ffff75ea498 has
0x7ffff75e55e8 as its canonical-type but differs in alias set and,
well, has its own chain of field_decls.
I'm not sure what this means, though. I suppose the code should then
(at least for non-unions?) rely on offsets rather than on pointer
comparison?