public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/49971] New: Missing "uninitialized" warning; may involve "return" statements
@ 2011-08-04  0:29 cernekee at gmail dot com
  2011-08-04  0:56 ` [Bug middle-end/49971] " pinskia at gcc dot gnu.org
  2011-08-04  8:43 ` manu at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: cernekee at gmail dot com @ 2011-08-04  0:29 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Missing "uninitialized" warning; may involve "return"
                    statements
           Product: gcc
           Version: 4.5.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: cernekee@gmail.com


This code does not produce any warnings ("uninitialized" or otherwise) on gcc
4.4.3, 4.4.5, or 4.5.3:

int testcase(unsigned int in)
{
    int a = 0, b;

    a++;
    if (in == 1)
        return -1;
    b++;
    return a + b;
}

Command line: gcc -O2 -c test.c -o test.o -Wall

Disassembly:

0000000000000000 <testcase>:
   0:   b8 ff ff ff ff          mov    $0xffffffff,%eax
   5:   c3                      retq   

(IOW, it silently changed the entire function into "return -1")

Compiler:

$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--enable-multiarch --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc
--disable-werror --with-arch-32=i486 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 


gcc 4.2.0 and 4.3.5 do produce a warning, using the same command lines.

-O0 on gcc 4.4.3 / 4.4.5 / 4.5.3 does produce a warning.  -O[123s] do not.

If I leave "a" uninitialized, gcc will produce a warning.  "a" does not seem to
be strictly necessary to reproduce the problem involving "b".

If I assign the value of "b" to a global variable before returning, gcc will
produce a warning.


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

* [Bug middle-end/49971] Missing "uninitialized" warning; may involve "return" statements
  2011-08-04  0:29 [Bug c/49971] New: Missing "uninitialized" warning; may involve "return" statements cernekee at gmail dot com
@ 2011-08-04  0:56 ` pinskia at gcc dot gnu.org
  2011-08-04  8:43 ` manu at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-08-04  0:56 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |middle-end

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-08-04 00:55:52 UTC ---
This is the standard CCP optimization getting in the way of uninitialized
variable warnings.


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

* [Bug middle-end/49971] Missing "uninitialized" warning; may involve "return" statements
  2011-08-04  0:29 [Bug c/49971] New: Missing "uninitialized" warning; may involve "return" statements cernekee at gmail dot com
  2011-08-04  0:56 ` [Bug middle-end/49971] " pinskia at gcc dot gnu.org
@ 2011-08-04  8:43 ` manu at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: manu at gcc dot gnu.org @ 2011-08-04  8:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |manu at gcc dot gnu.org
         Resolution|                            |DUPLICATE

--- Comment #2 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-08-04 08:41:02 UTC ---
(In reply to comment #1)
> This is the standard CCP optimization getting in the way of uninitialized
> variable warnings.

Correct.

*** This bug has been marked as a duplicate of bug 18501 ***


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

end of thread, other threads:[~2011-08-04  8:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-04  0:29 [Bug c/49971] New: Missing "uninitialized" warning; may involve "return" statements cernekee at gmail dot com
2011-08-04  0:56 ` [Bug middle-end/49971] " pinskia at gcc dot gnu.org
2011-08-04  8:43 ` manu 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).