This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Add uninitialized attribute?
On 8/31/2010 1:19 AM, Andrew Haley wrote:
> On 08/30/2010 03:50 PM, Vincent Lefevre wrote:
>> On 2010-08-30 14:46:57 +0200, Michael Matz wrote:
>>> int x = x;
>>>
>>> is the way GCC offers this idiom since about forever, no need for an
>>> attribute. Downthread I see that people worry about this generating an
>>> actual (uninitialized) access to x. They are confused.
>>
>> This is not a good idea as "int x = x;" may really generate an
>> (uninitialized) access to x with other compilers.
>
> Absolutely so. I suspect it's even undefined behaviour in the standard
> language. There's no way that this idiom should appear anywhere in
> GNU code.
I agree; an attribute, or the __unitialized__ keyword would be much cleaner.
On the other hand, I think GCC should continue to accept "int x = x;" as
a synonym for the forseeable future; whether or not it's good language
design it has been a de facto part of GNU C for a long time.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713