public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/52078] New: Bogus may be used uninitialized warning
@ 2012-02-01  2:38 rmansfield at qnx dot com
  2012-02-01  8:18 ` [Bug middle-end/52078] " manu at gcc dot gnu.org
  2012-02-01  9:29 ` rguenth at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: rmansfield at qnx dot com @ 2012-02-01  2:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52078

             Bug #: 52078
           Summary: Bogus may be used uninitialized warning
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: rmansfield@qnx.com
              Host: x86_64-linux-gnu
            Target: x86_64-linux-gnu
             Build: x86_64-linux-gnu


gcc version 4.7.0 20120201 (experimental) [trunk revision 183790] (GCC) 

Testcase:

#include <string.h>

int
foo (char *nname, char *oname)
{
  int cmp;

  while (nname != oname && (cmp = strcmp (nname, oname)) < 0)
    {
      break;
    }
  if (nname == oname || cmp == 0)
    {
      return 1;
    }
  else
    {
      return 0;
    }
}


$ ./xgcc -B. -O2 -Wall ~/init.c -c 
/home/ryan/init.c: In function 'foo':
/home/ryan/init.c:12:29: warning: 'cmp' may be used uninitialized in this
function [-Wmaybe-uninitialized]

Since both && and || operators guarantee left-to-right evaluation, in the case
where nname == oname, strcmp is never called but in the (name == oname || cmp
== 0) expression, nname == oname and the second operand is not evaluated so cmp
is never used uninitialized.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug middle-end/52078] Bogus may be used uninitialized warning
  2012-02-01  2:38 [Bug c/52078] New: Bogus may be used uninitialized warning rmansfield at qnx dot com
@ 2012-02-01  8:18 ` manu at gcc dot gnu.org
  2012-02-01  9:29 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: manu at gcc dot gnu.org @ 2012-02-01  8:18 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52078

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-02-01 08:17:27 UTC ---
I haven't followed development for a while, but I don't think GCC uninit
analysis is powerful enough to detect this or even simpler cases like PR36550
and PR20968.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug middle-end/52078] Bogus may be used uninitialized warning
  2012-02-01  2:38 [Bug c/52078] New: Bogus may be used uninitialized warning rmansfield at qnx dot com
  2012-02-01  8:18 ` [Bug middle-end/52078] " manu at gcc dot gnu.org
@ 2012-02-01  9:29 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-02-01  9:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52078

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-02-01
             Blocks|                            |24639
     Ever Confirmed|0                           |1

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-02-01 09:28:49 UTC ---
Yeah, it's simply too confusing code for GCCs static analysis.  Thus the "may
be used uninitialized".


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-02-01  9:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-01  2:38 [Bug c/52078] New: Bogus may be used uninitialized warning rmansfield at qnx dot com
2012-02-01  8:18 ` [Bug middle-end/52078] " manu at gcc dot gnu.org
2012-02-01  9:29 ` rguenth at gcc dot gnu.org

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).