On 2010-02-03 15:02, Michael Cree wrote:
> On 04/02/10 07:55, Soeren Sandmann wrote:
>>
>> I recently turned it on in pixman because completely reasonable code
>> like this:
>>
>> void
>> pixman_contract (uint32_t * dst,
>> const uint64_t *src,
>> int width)
>> {
>> int i;
>>
>> /* Start at the beginning so that we can do the contraction in
>> * place when src == dst
>> */
>> is actually illegal under the C aliasing rules, and GCC can and will
>> break it unless you use -fno-strict-aliasing.
>
> I'm confused. Why does this break the aliasing rules?
If *dst and *src point to (alias) the same memory, it breaks the rules
since they are different types. The compiler is free to assume that dst
and src are disjoint. It may eg. unroll the loop and re-order the loads
and stores, resulting in something the programmer didn't expect if they
do overlap.
Peter Harris
--
Open Text Connectivity Solutions Group
Peter Harris http://connectivity.opentext.com/
Research and Development Phone: +1 905 762 6001
[email protected] Toll Free: 1 877 359 4866
_______________________________________________
xorg-devel mailing list
[email protected]
http://lists.x.org/mailman/listinfo/xorg-devel