C99: Suggestions for style(9)

Christoph Mallon christoph.mallon at gmx.de
Sun May 17 16:41:17 UTC 2009


Stanislav Sedov schrieb:
> On Sun, 17 May 2009 14:36:03 +0200
> Christoph Mallon <christoph.mallon at gmx.de> mentioned:
> 
>>> Aliasing behavior is stritcly described in
>>> ISO C99 standard, so there's a good point to enforcing strict-aliasing clear
>>> code in our kernel.
>> If you like this addition because of this reason, I have to disappoint 
>> you: This addition has absolutly *nothing* to do with strict-aliasing.
>>
> 
> I didn't meant I like this change only from aliasing point of view: certianly,
> the code readability argument is very important. But this change also
> works towards the strict aliasing problem solving too: there's just
> a less chance someone will reuse a variable, address of which was
> previously taken.

Something like this would violate strict-aliasing:
int i;
short* p = (short*)&i;
A short pointer may never point at an int object (ISO/IEC 9899:1999 (E) 
§6.5:7).

The suggested paragraph has nothing to do with strict-aliasing. It's 
"just" about reusing the same variable in different contexts. Reusing 
the same variable in different contexts is bad, because it's harder for 
a human reader to identify the def-use-chains and additionally if the 
address of the variable has escaped (just a "normal" alias problem, 
nothing about type-punning and strict-aliasing) the generated code will 
be worse.

Please, can we stop this now? It was already rejected. It's a pity, but 
maintaining status quo for style(9) seems to be too holy. *sigh*

	Christoph


More information about the freebsd-hackers mailing list