> The trigger is a latent problem in the ada gcc_interface. > > That is we have a bit-field of exactly 8 bit size, which is not > byte-aligned, but DECL_MODE=QImode, DECL_BIT_FIELD=false which looks quite > strange, and is totally different from how C structures look like. I should > mention that there are even some places in the target back-ends, where the > attribute DECL_BIT_FIELD is used for whatever.
This needs to be investigated because the intent is very clear in gigi, see create_field_decl and finish_record_type: we set DECL_BIT_FIELD conservatively and clear it only when we know that we can. This code is quite old now. > However even without that patch, I can arrange for "volatilep && > flag_strict_volatile_bitfields> 0" to be true in Ada (even on X86_64, or > whatever platform you like): > > -- { dg-do run } > -- { dg-options "-gnatp -fstrict-volatile-bitfields" } > > procedure Misaligned_Volatile is > > type Byte is mod 2**8; > > type Block is record > B : Boolean; > V : Byte; > end record; > pragma Volatile (Block); > pragma Pack (Block); > for Block'Alignment use 1; > > type Pair is array (1 .. 2) of Block; > > P : Pair; > begin > for K in P'Range loop > P(K).V := 237; > end loop; > for K in P'Range loop > if P(K).V /= 237 then > raise Program_error; > end if; > end loop; > end; > > > This Ada test case causes either wrong code generation or an ICE at compile > time, if the -fstrict-volatile-bitfields option is either given by the > user, or by the target-specific default as it is on ARM for instance > (which is completely pointless on Ada, I know!)... The test indeed raises Program_Error on x86-64. -- Eric Botcazou