On Fri, Aug 20, 2010 at 1:57 PM, Bernd Schmidt <ber...@codesourcery.com> wrote:
> On 08/20/2010 10:51 PM, Ian Lance Taylor wrote:
>> "H.J. Lu" <hjl.to...@gmail.com> writes:
>>
>>> Sometime I have to do
>>>
>>> int x = 0;
>>>
>>> to silence gcc from uninitialized warnings when I know it is
>>> unnecessary.  Is that a good idea to add
>>>
>>> int x __attribute__ ((uninitialized));
>>>
>>> to tell compiler that it is OK for "x" to be uninitialized?
>
> Better to call it "initialized", analogous to attribute used/unused.
>
>> I think the general idea is reasonable.  I also think it might be worth
>> spending a few minutes thinking about whether we can implement some more
>> general diagnostic suppression mechanism.  E.g.,
>>    int x __attribute__ ((ignore ("-Wuninitialized")));
>
> Or this.
>

Another usage for this it to specify a value which we don't care
and must provide when calling a function due to function prototype.
Currently I have to do

foo (NULL);

Instead I can do

void *undef __attribute__ ((uninitialized)); // Or something similar

foo (undef);

Compiler can pass some junk to foo.


-- 
H.J.

Reply via email to