git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Fix an "variable might be used uninitialized" gcc warning

From
Miles Bader <miles@gnu.org>
Date
Feb 1, 2012, 07:16 UTC
Message-ID
<buo7h07rpl8.fsf@dhlpc061.dev.necel.com>
In-Reply-To
<20120131194302.GD12443@burratino>
Jonathan Nieder <jrnieder@gmail.com> writes:
Show 18 quoted lines
>> The versions which complain are 3.4.4 and 4.1.2, whereas 4.4.0 compiles
>> the code without complaint. So, gcc *may* be getting more sane, but I wouldn't
>> bet on it! :-P
>>
>> I've had examples of this kind of warning, which relies heavily on the
>> analysis performed primarily for the optimizer, come-and-go in gcc before
>
> Yep, judging from the commit message, Junio found the same warning
> in 4.6.2.
>
>> Having said that, unless you are going to decree that the project only
>> supports gcc (and presumably only some particular versions of gcc), then you
>> may well find similar warnings triggered when using other compilers anyway ...
>
> Sure, when the control flow grows too complicated, that's probably worth
> fixing anyway, for the sake of humans especially.
>
> Sometimes gcc is the only crazy one, though. ;-)

It's hard to see how any compiler could detect that "mode" always receives a value here .... it would have to realize that "stage" always becomes 2 before the loop is exited, and that seems to depend on non-trivial properties of external data structures...

-miles
-- 
Joy, n. An emotion variously excited, but in its highest degree arising from
the contemplation of grief in another.
Previous: Jonathan NiederNext: Ramsay Jones
Message 6 of 7 in “Fix an "variable might be used uninitialized" gcc warning”
  1. Fix an "variable might be used uninitialized" gcc warningRamsay Jones, Dec 16, 2011
  2. Jonathan NiederDec 16, 2011
  3. Andreas SchwabDec 17, 2011
  4. Ramsay JonesJan 31, 2012
  5. Jonathan NiederJan 31, 2012
  6. Miles BaderFeb 1, 2012
  7. Ramsay JonesFeb 2, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.