public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/58236] New: -Wuninitialized doesn't report uninitialised variable as expected
@ 2013-08-24  6:38 noufal at nibrahim dot net.in
  2013-08-24  7:35 ` [Bug c/58236] " glisse at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: noufal at nibrahim dot net.in @ 2013-08-24  6:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58236
           Summary: -Wuninitialized doesn't report uninitialised variable
                    as expected
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: noufal at nibrahim dot net.in

Created attachment 30695
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30695&action=edit
Test case program

Command run
-----------
gcc was run like so
      gcc -Wall program.c
I also tried running
      gcc -Wuninitialized program.c

The program is attached to this bug report.

Behaviour
---------

#include <stdio.h>

void test()
{
  int iters; 

  while(iters++ <= 100) {
    printf("%d\n", iters);
  }

}

int main() 
{
  test();
  return 0;
}


In the program above, the 'iters' variable is not initialised. This makes the
loop sometimes behave in unexpected ways. Ideally, the -Wuninitialized option
should warn about this. This doesn't happen. 

With clang, I get the following output
noufal@sanitarium% clang -Wall program.c
program.c:7:9: warning: variable 'iters' is uninitialized when used here
[-Wuninitialized]
  while(iters++ <= 100) {
        ^~~~~
program.c:5:12: note: initialize the variable 'iters' to silence this warning
  int iters;
           ^
            = 0
1 warning generated.

I tested this with the stock Debian gcc (4.6.3) but friends have tried it on
4.6, 4.7 and 4.8 and reported the same problem.


gcc -v output
--------------
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-1'
--with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin
--enable-objc-gc --with-arch-32=i586 --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.6.3 (Debian 4.6.3-1) 


System type
-----------
uname -a output:
Linux sanitarium 3.1.0-1-amd64 #1 SMP Sun Dec 11 20:36:41 UTC 2011 x86_64
GNU/Linux

This is running on an Lenovo Thinkpad X201.


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

* [Bug c/58236] -Wuninitialized doesn't report uninitialised variable as expected
  2013-08-24  6:38 [Bug c/58236] New: -Wuninitialized doesn't report uninitialised variable as expected noufal at nibrahim dot net.in
@ 2013-08-24  7:35 ` glisse at gcc dot gnu.org
  2013-08-24  8:59 ` noufal at nibrahim dot net.in
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-08-24  7:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> ---
Note, from the documentation of -Wuninitialized:

"Because these warnings depend on optimization, the exact variables or elements
for which there are warnings depends on the precise optimization options and
version of GCC used."

You need to pass -O2 on the command line, and then you'll get warnings.


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

* [Bug c/58236] -Wuninitialized doesn't report uninitialised variable as expected
  2013-08-24  6:38 [Bug c/58236] New: -Wuninitialized doesn't report uninitialised variable as expected noufal at nibrahim dot net.in
  2013-08-24  7:35 ` [Bug c/58236] " glisse at gcc dot gnu.org
@ 2013-08-24  8:59 ` noufal at nibrahim dot net.in
  2013-10-30 21:04 ` law at redhat dot com
  2013-10-31  0:50 ` manu at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: noufal at nibrahim dot net.in @ 2013-08-24  8:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Noufal Ibrahim <noufal at nibrahim dot net.in> ---
That solves the issue although I find the relationship between the
optimisations and the warnings somewhat tenuous atleast from a user
perspective. Would it not be a good idea to have this warning even by default?


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

* [Bug c/58236] -Wuninitialized doesn't report uninitialised variable as expected
  2013-08-24  6:38 [Bug c/58236] New: -Wuninitialized doesn't report uninitialised variable as expected noufal at nibrahim dot net.in
  2013-08-24  7:35 ` [Bug c/58236] " glisse at gcc dot gnu.org
  2013-08-24  8:59 ` noufal at nibrahim dot net.in
@ 2013-10-30 21:04 ` law at redhat dot com
  2013-10-31  0:50 ` manu at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: law at redhat dot com @ 2013-10-30 21:04 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |law at redhat dot com
         Resolution|---                         |WONTFIX

--- Comment #3 from Jeffrey A. Law <law at redhat dot com> ---
I agree it's not ideal and there's been some proposals to change it that have
never gotten any traction -- largely because many folks find the alternatives
even worse because they'll generate many more false positives than the current
implementation.


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

* [Bug c/58236] -Wuninitialized doesn't report uninitialised variable as expected
  2013-08-24  6:38 [Bug c/58236] New: -Wuninitialized doesn't report uninitialised variable as expected noufal at nibrahim dot net.in
                   ` (2 preceding siblings ...)
  2013-10-30 21:04 ` law at redhat dot com
@ 2013-10-31  0:50 ` manu at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: manu at gcc dot gnu.org @ 2013-10-31  0:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Noufal Ibrahim from comment #2)
> That solves the issue although I find the relationship between the
> optimisations and the warnings somewhat tenuous atleast from a user
> perspective. Would it not be a good idea to have this warning even by
> default?

You can find a very detailed description of the problems involved at:

http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings#Current_Situation

The relationship is easy to explain:

* More precise warnings require more expensive analysis
* The expensive analysis are only done when optimizations are enabled
* So you get more precise warnings when enabling more optimizations.

There are some ideas in that page on how to tackle these issues, but nothing is
sure to work reliably and all of them require considerable effort and time.
Until someone very determined steps up to the challenge, there will be little
progress.

*** This bug has been marked as a duplicate of bug 43361 ***
>From gcc-bugs-return-433118-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Oct 31 00:50:10 2013
Return-Path: <gcc-bugs-return-433118-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 29004 invoked by alias); 31 Oct 2013 00:50:09 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 28945 invoked by uid 48); 31 Oct 2013 00:50:06 -0000
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/43361] missing uninitialized warning without optimization (loop representation)
Date: Thu, 31 Oct 2013 00:50:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: manu at gcc dot gnu.org
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-43361-4-rtq8XePERn@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-43361-4@http.gcc.gnu.org/bugzilla/>
References: <bug-43361-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-10/txt/msg02262.txt.bz2
Content-length: 487

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |noufal at nibrahim dot net.in

--- Comment #7 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
*** Bug 58236 has been marked as a duplicate of this bug. ***
>From gcc-bugs-return-433121-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Oct 31 01:01:48 2013
Return-Path: <gcc-bugs-return-433121-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 8544 invoked by alias); 31 Oct 2013 01:01:48 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 8296 invoked by uid 55); 31 Oct 2013 01:01:45 -0000
From: "singhai at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/58134] [4.8/4.9 Regression] -ftree-vectorizer-verbose=<n> shows vectorized loops only for N== 1 and N >2 but not for N==2
Date: Thu, 31 Oct 2013 01:01:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: diagnostic
X-Bugzilla-Severity: normal
X-Bugzilla-Who: singhai at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.8.3
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-58134-4-xSak11HUvB@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58134-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58134-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-10/txt/msg02265.txt.bz2
Content-length: 939

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX134

--- Comment #6 from Sharad Singhai <singhai at gcc dot gnu.org> ---
Author: singhai
Date: Thu Oct 31 01:01:40 2013
New Revision: 204244

URL: http://gcc.gnu.org/viewcvs?rev 4244&root=gcc&view=rev
Log:
2013-10-30  Sharad Singhai  <singhai@google.com>

    PR middle-end/58134
    * opts.c (common_handle_option): Remove deprecated option
    -ftree-vectorizer-verbose.
    * doc/invoke.texi (Debugging Options): Ditto.
    * opts-global.c (handle_common_deferred_options): Ditto.
    (dump_remap_tree_vectorizer_verbose): Delete.
    * common.opt: Set -ftree-vectorizer-verbose as an ignored option.

ada/ChangeLog
    * gnat_ugn.texi: Remove option description for PR middle-end/58134.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ada/ChangeLog
    trunk/gcc/ada/gnat_ugn.texi
    trunk/gcc/common.opt
    trunk/gcc/doc/invoke.texi
    trunk/gcc/opts-global.c
    trunk/gcc/opts.c


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

end of thread, other threads:[~2013-10-31  0:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-24  6:38 [Bug c/58236] New: -Wuninitialized doesn't report uninitialised variable as expected noufal at nibrahim dot net.in
2013-08-24  7:35 ` [Bug c/58236] " glisse at gcc dot gnu.org
2013-08-24  8:59 ` noufal at nibrahim dot net.in
2013-10-30 21:04 ` law at redhat dot com
2013-10-31  0:50 ` 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).