Re: x86/64 alignment, optimization, -Wcast-align

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 26, 2016 at 4:01 PM, Martin Sebor <msebor@xxxxxxxxx> wrote:
>> I believe -Wcast-align should be made to warn on x86/64 as well, in
>> the light of the above, as now it is the most dangerous territory,
>> where you only get crashes if the compiler decides to vectorize code
>> AND you get unaligned memory (the crash I got was VERY hard to
>> reproduce).
>>
>> The problem I see is a conflict between the C standard (accesses must
>> be aligned for int, etc.) and the x86/64 machine (accesses need not be
>> aligned for int, etc.), and GCC optimizations using the former, while
>> the warning flag (-Wcast-align) taking the latter.
>>
>> I would like more comments, ideas on this in general as well.
>
>
> -Wcast-align depends on the STRICT_ALIGNMENT GCC macro being
> non-zero.  The macro is set to zero for i386 which effectively
> disables the warning.
>
> I agree that it would be useful to enable -Wcast-align even for
> targets that tolerate unaligned accesses, not just for the reason
> you mention but also to help detect invalid alignment assumptions
> that may happen to be safe on the current target but not on others.

-fsanitize=alignment ?

https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html

-- 
Mathieu



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux