* Missing "var is used uninitialized" warning?
@ 2011-09-17 20:33 Georg-Johann Lay
2011-09-17 20:35 ` Jonathan Wakely
0 siblings, 1 reply; 5+ messages in thread
From: Georg-Johann Lay @ 2011-09-17 20:33 UTC (permalink / raw)
To: gcc-help
Hi, compiled with -Wall -Wextra the wollowing lines don't complain about
a being used uninitialized. Tried with 4.5 and 4.6. Am I missing
something?
int func (void)
{
int a = a;
return a;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Missing "var is used uninitialized" warning?
2011-09-17 20:33 Missing "var is used uninitialized" warning? Georg-Johann Lay
@ 2011-09-17 20:35 ` Jonathan Wakely
2011-09-17 20:43 ` Georg-Johann Lay
0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Wakely @ 2011-09-17 20:35 UTC (permalink / raw)
To: Georg-Johann Lay; +Cc: gcc-help
On 17 September 2011 21:32, Georg-Johann Lay wrote:
> Hi, compiled with -Wall -Wextra the wollowing lines don't complain about a
> being used uninitialized. Tried with 4.5 and 4.6. Am I missing something?
>
> int func (void)
> {
> int a = a;
>
> return a;
> }
Yes, you're missing -Winit-self
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Missing "var is used uninitialized" warning?
2011-09-17 20:35 ` Jonathan Wakely
@ 2011-09-17 20:43 ` Georg-Johann Lay
2011-09-17 20:48 ` Jonathan Wakely
0 siblings, 1 reply; 5+ messages in thread
From: Georg-Johann Lay @ 2011-09-17 20:43 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: gcc-help
Jonathan Wakely schrieb:
> On 17 September 2011 21:32, Georg-Johann Lay wrote:
>
>>Hi, compiled with -Wall -Wextra the wollowing lines don't complain about a
>>being used uninitialized. Tried with 4.5 and 4.6. Am I missing something?
>>
>>int func (void)
>>{
>> int a = a;
>>
>> return a;
>>}
>
> Yes, you're missing -Winit-self
Thanks.
Confusing... extra option for that?
The message with -Wuninitialized -Winit-self is
warning: 'a' is used uninitialized in this function [-Wuninitialized]
Is there a special reason why this is not part of Wall or Wextra?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Missing "var is used uninitialized" warning?
2011-09-17 20:43 ` Georg-Johann Lay
@ 2011-09-17 20:48 ` Jonathan Wakely
2011-09-18 14:38 ` Georg-Johann Lay
0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Wakely @ 2011-09-17 20:48 UTC (permalink / raw)
To: Georg-Johann Lay; +Cc: gcc-help
On 17 September 2011 21:42, Georg-Johann Lay wrote:
> Jonathan Wakely schrieb:
>>
>> On 17 September 2011 21:32, Georg-Johann Lay wrote:
>>
>>> Hi, compiled with -Wall -Wextra the wollowing lines don't complain about
>>> a
>>> being used uninitialized. Tried with 4.5 and 4.6. Am I missing
>>> something?
>>>
>>> int func (void)
>>> {
>>> int a = a;
>>>
>>> return a;
>>> }
>>
>> Yes, you're missing -Winit-self
>
> Thanks.
>
> Confusing... extra option for that?
Maybe, but it's documented, so that makes it ok!
> The message with -Wuninitialized -Winit-self is
> warning: 'a' is used uninitialized in this function [-Wuninitialized]
>
> Is there a special reason why this is not part of Wall or Wextra?
Initialising a variable with itself is a GNU extension, used to
suppress warnings about uninitialised variables when you *really*
don't want to initialise a variable and don't want a warning either.
Personally I think it's an abomination :)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Missing "var is used uninitialized" warning?
2011-09-17 20:48 ` Jonathan Wakely
@ 2011-09-18 14:38 ` Georg-Johann Lay
0 siblings, 0 replies; 5+ messages in thread
From: Georg-Johann Lay @ 2011-09-18 14:38 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: gcc-help
Jonathan Wakely schrieb:
> On 17 September 2011 21:42, Georg-Johann Lay wrote:
>
>>Jonathan Wakely schrieb:
>>
>>>On 17 September 2011 21:32, Georg-Johann Lay wrote:
>>>
>>>
>>>>Hi, compiled with -Wall -Wextra the wollowing lines don't complain about
>>>>a
>>>>being used uninitialized. Tried with 4.5 and 4.6. Am I missing
>>>>something?
>>>>
>>>>int func (void)
>>>>{
>>>> int a = a;
>>>>
>>>> return a;
>>>>}
>>>
>>>Yes, you're missing -Winit-self
>>
>>Thanks.
>>
>>Confusing... extra option for that?
>
> Maybe, but it's documented, so that makes it ok!
>
>>The message with -Wuninitialized -Winit-self is
>>warning: 'a' is used uninitialized in this function [-Wuninitialized]
>>
>>Is there a special reason why this is not part of Wall or Wextra?
>
> Initialising a variable with itself is a GNU extension, used to
> suppress warnings about uninitialised variables when you *really*
> don't want to initialise a variable and don't want a warning either.
Thanks for the explanation, now I understand it.
> Personally I think it's an abomination :)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-09-18 14:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-17 20:33 Missing "var is used uninitialized" warning? Georg-Johann Lay
2011-09-17 20:35 ` Jonathan Wakely
2011-09-17 20:43 ` Georg-Johann Lay
2011-09-17 20:48 ` Jonathan Wakely
2011-09-18 14:38 ` Georg-Johann Lay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).