RFC: ms bitfields of aligned basetypes

Joern RENNECKE joern.rennecke@st.com
Mon Apr 25 14:26:00 GMT 2005


Danny Smith wrote:

>Jim Wilson wrote http://gcc.gnu.org/ml/gcc/2005-04/msg01172.html
>
>
>  
>
>>Joern RENNECKE wrote: 
>>    
>>
>>>required for Tal16bool. Should we enforce that any storage element
>>>      
>>>
>allocated
>  
>
>>>for a run of ms-bitfields get the full alignment of the basetype,
>>>      
>>>
>even when it exceeds
>  
>
>>>the size of the basetype and of BIGGEST_ALIGNMENT? 
>>>      
>>>
>>Obviously, we should do the exact same thing that the microsoft
>>    
>>
>compiler
>  
>
>>does. That is the whole point of -mms-bitfields.
>>
>>If we can't generate an equivalent testcase for the microsoft
>>    
>>
>compiler,
>  
>
>>because it doesn't have aligned attributes or equivalent, then we can
>>    
>>
>do
>  
>
>>whatever seems to make sense.
>>
>>    
>>
>
>I believe the MS equivalent is __declspec (align (16)).  Could you test
>the following patch to 
>i386/cygming.h to see if you come closer to MS behaviour (I don't have a
>MS compiler handy). 
>
Sorry, my time is currently taken up by some other work.
The background of my query was this: while doing regression the 
sh-elf-4_1 branch,
I found that some of the struct-layout superficial regressions were 
actually due to use of
unitialized memory in the ms-bitfield code, as reported before in PR 
middle-end/20371.
After applying the patch from December to the branch. I found some new 
regressions,
which led me to write an additional patch, which can be found in the PR 
as attachment
from the 15th April.  This new patch contains an gcc_assert that checks that
actual_align >= type_align whenever storage for a new run of bitfields 
is allocated.
This assert triggered for a number of the struct-layout cases, which 
lead to my query.
I found that a run of bitfields was allocated to only 64 bit alignment, 
even though the
type said it should be 128 bit aligned (although baed on bool).

I don't have a cygwin test platform, I have been doing sh64-elf 
regression tests using the
simulator available in the contrib directory of gdb.




More information about the Gcc mailing list