Bug 10538 - no warning for "int a = a + 1" statements
Summary: no warning for "int a = a + 1" statements
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: 3.4.0
Assignee: Andrew Pinski
URL:
Keywords: diagnostic
: 5284 10539 12651 14739 (view as bug list)
Depends on:
Blocks: Wuninitialized
  Show dependency treegraph
 
Reported: 2003-04-29 14:06 UTC by invi
Modified: 2005-11-02 19:17 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-08-03 15:08:50


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Bangerth 2003-04-29 09:30:29 UTC
From: Wolfgang Bangerth <bangerth@ices.utexas.edu>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/10538: gcc 3.2.3 does not issue a warning for "int a = a +
 1" statements (fwd)
Date: Tue, 29 Apr 2003 09:30:29 -0500 (CDT)

 ---------- Forwarded message ----------
 Date: Tue, 29 Apr 2003 16:35:46 +0200
 From: Remo Inverardi <invi@your.toilet.ch>
 To: bangerth@dealii.org
 Subject: Re: c++/10538: gcc 3.2.3 does not issue a warning for "int a = a +
     1" statements
 
  > You actually use a documented gcc extension to _suppress_ the
  > warning. I don't think I have an opinion about the usefulness
  > of this extension, so leave it to others to decide what to do
  > with the report.
 
 I just gave the current GCC documentation a second look, but I was not 
 able to identify the extension your referring to (?) ... what's more, I 
 just tried compiling the same code with -ansi, -pedantic, and -Wall 
 options, neither of which gave me a warning ...
 

Comment 1 Wolfgang Bangerth 2003-04-29 09:32:28 UTC
From: Wolfgang Bangerth <bangerth@ices.utexas.edu>
To: Remo Inverardi <invi@your.toilet.ch>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/10538: gcc 3.2.3 does not issue a warning for "int a = a +
 1" statements
Date: Tue, 29 Apr 2003 09:32:28 -0500 (CDT)

 > I just gave the current GCC documentation a second look, but I was not 
 > able to identify the extension your referring to (?) ...
 
 Maybe you're right. I tried to locate it in the manual some time ago and 
 couldn't find it either, after it had been discussed on the mailing lists 
 for the umpteenth time. It's documented in the mailing list archives, but 
 that is not a very good place...
 
 > what's more, I 
 > just tried compiling the same code with -ansi, -pedantic, and -Wall 
 > options, neither of which gave me a warning ...
 
 That's why I didn't close the report. 
 
 W.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:            bangerth@ices.utexas.edu
                                www: http://www.ices.utexas.edu/~bangerth/
Comment 2 invi 2003-04-29 14:06:00 UTC
The following code compiles without any warnings:

void foo()
{
  int xxx = xxx + 1;
}

I think some warning like "xxx was accessed without being initialized" would be appropriate.

Release:
gcc-3.2.3

Environment:
Debian SID

How-To-Repeat:
See description.
Comment 3 Wolfgang Bangerth 2003-04-29 14:16:19 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: You actually use a documented gcc extension to _suppress_
    the warning. I don't think I have an opinion about the
    usefulness of this extension, so leave it to others to
    decide what to do with the report. 
    
    In any case, I can confirm the behavior with present
    mainline (3.4).
    
    W.
Comment 4 Andrew Pinski 2003-08-07 04:24:32 UTC
I am working on a patch.
Comment 5 Andrew Pinski 2003-08-17 05:06:56 UTC
I submitted a patch to fix this: <http://gcc.gnu.org/ml/gcc-patches/2003-08/
msg00952.html>.
Comment 6 Andrew Pinski 2003-08-17 22:57:15 UTC
*** Bug 5284 has been marked as a duplicate of this bug. ***
Comment 7 CVS Commits 2003-08-19 20:29:05 UTC
Subject: Bug 10538

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pinskia@gcc.gnu.org	2003-08-19 20:29:01

Modified files:
	gcc            : c-common.h c.opt c-opts.c c-lang.c function.c 
	gcc/objc       : objc-lang.c 
	gcc/doc        : invoke.texi 
	gcc/cp         : cp-lang.c 

Log message:
	PR c++/10538, PR c/5582
	
	ChangeLog:
	* langhooks-def.h (lhd_decl_uninit): Declare.
	(LANG_HOOKS_DECL_UNINIT): New macro.
	(LANG_HOOKS_INITIALIZER): Adjust.
	* langhooks.h (struct lang_hooks): Add new field
	decl_uninit.
	* langhooks.c (lhd_decl_uninit): Define.
	* c-common.c (c_decl_uninit_1): New function.
	(c_decl_uninit): New function.
	(warn_init_self): Define.
	* c-common.h (c_decl_uninit): Declare.
	(warn_init_self): Declare.
	* c.opt: Introduce -Winit-self.
	* c-opts.c (c_common_handle_options): Set warn_init_self.
	* c-lang.c (LANG_HOOKS_DECL_UNINIT): Define.
	* objc/objc-lang.c  (LANG_HOOKS_DECL_UNINIT): Define.
	* function.c (uninitialized_vars_warning): Call the language hook.
	* doc/invoke.texi: Document -Winit-self.
	
	cp/ChangeLog:
	* cp/cp-lang.c (LANG_HOOKS_DECL_UNINIT): Define.
	
	testsuite:
	* gcc.dg/uninit-D.c: New Test.
	* gcc.dg/uninit-E.c: New Test.
	* gcc.dg/uninit-F.c: New Test.
	* gcc.dg/uninit-G.c: New Test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-common.h.diff?cvsroot=gcc&r1=1.202&r2=1.203
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c.opt.diff?cvsroot=gcc&r1=1.14&r2=1.15
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-opts.c.diff?cvsroot=gcc&r1=1.87&r2=1.88
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-lang.c.diff?cvsroot=gcc&r1=1.114&r2=1.115
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/function.c.diff?cvsroot=gcc&r1=1.449&r2=1.450
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/objc/objc-lang.c.diff?cvsroot=gcc&r1=1.37&r2=1.38
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/invoke.texi.diff?cvsroot=gcc&r1=1.328&r2=1.329
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-lang.c.diff?cvsroot=gcc&r1=1.61&r2=1.62

Comment 8 Andrew Pinski 2003-08-19 20:33:29 UTC
Fixed on the mainline for 3.4.
Comment 9 Andrew Pinski 2003-10-16 21:46:29 UTC
*** Bug 12651 has been marked as a duplicate of this bug. ***
Comment 10 Andrew Pinski 2004-03-26 05:03:08 UTC
*** Bug 14739 has been marked as a duplicate of this bug. ***