[PATCH] Fix C++0x memory model for -fno-strict-volatile-bitfields on ARM

Eric Botcazou ebotcazou@adacore.com
Mon Dec 2 23:19:00 GMT 2013


> Good question. Most of the time the expansion can not know if it expands
> Ada, C, or Fortran. In this case we know it can only be Ada, so the C++
> memory model is not mandatory. Maybe Eric can tell, if a data store race
> condition may be an issue in Ada if  structure is laid out like
> __attribute((packed,aligned(1))) I mean, if that is at all possible.

Unlike in C++, all bets are off in Ada as soon as you have non-byte-aligned 
objects.  For byte-aligned objects, there is the following implementation 
advice (C.6 2/22):

"A load or store of a volatile object whose size is a multiple of 
System.Storage_Unit and whose alignment is nonzero, should be implemented by 
accessing exactly the bits of the object and no others."

so the answer is (theoritically) yes for volatile fields.  But, in practice, 
we probably reject the potentially problematic volatile fields in gigi.

-- 
Eric Botcazou



More information about the Gcc-patches mailing list