* [Bug c++/34772] -Winit-self ignored when compiling C++ (and ObjC++)
2008-01-13 18:24 [Bug c++/34772] New: -Winit-self ignored when compiling C++ (and ObjC++) olly at survex dot com
@ 2008-01-13 18:50 ` olly at survex dot com
2008-01-14 1:12 ` manu at gcc dot gnu dot org
` (13 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: olly at survex dot com @ 2008-01-13 18:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from olly at survex dot com 2008-01-13 18:23 -------
I've just noticed that Debian have a packaged 4.3 snapshot:
g++-4.3 (Debian 4.3-20080104-1) 4.3.0 20080104 (experimental) [trunk revision
131316]
Testing with this shows the same behaviour for C++.
--
olly at survex dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |3.4.4 4.2.1 4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/34772] -Winit-self ignored when compiling C++ (and ObjC++)
2008-01-13 18:24 [Bug c++/34772] New: -Winit-self ignored when compiling C++ (and ObjC++) olly at survex dot com
2008-01-13 18:50 ` [Bug c++/34772] " olly at survex dot com
@ 2008-01-14 1:12 ` manu at gcc dot gnu dot org
2008-01-14 1:36 ` olly at survex dot com
` (12 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-01-14 1:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from manu at gcc dot gnu dot org 2008-01-14 00:42 -------
Good catch!
Well, there is something weird going on
$ cc1 -fdump-tree-original -O winit-self.c
{
int i = i;
int i = i;
return i;
}
$ cc1plus -fdump-tree-original -O winit-self.c
{
int i;
int i;
<<cleanup_point <<< Unknown tree: expr_stmt
(void) (i = i) >>>
>>;
return <retval> = i;
}
The first problem is that C++ FE does not generate a DECL_EXPR but a BIND_EXPR,
so it does not trigger the conditional in c-gimplify.c (c_gimplify_expr). My
guess is that this have never worked in C++. So we can just delete this option
from the C++ FE and convert this to an enhancement request. If none disagrees,
I will submit a patch in the next days.
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |diagnostic
Last reconfirmed|0000-00-00 00:00:00 |2008-01-14 00:42:56
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/34772] -Winit-self ignored when compiling C++ (and ObjC++)
2008-01-13 18:24 [Bug c++/34772] New: -Winit-self ignored when compiling C++ (and ObjC++) olly at survex dot com
2008-01-13 18:50 ` [Bug c++/34772] " olly at survex dot com
2008-01-14 1:12 ` manu at gcc dot gnu dot org
@ 2008-01-14 1:36 ` olly at survex dot com
2008-01-14 7:43 ` [Bug c++/34772] self-initialisation does not silence uninitialised warnings (-Winit-self ignored) manu at gcc dot gnu dot org
` (11 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: olly at survex dot com @ 2008-01-14 1:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from olly at survex dot com 2008-01-14 00:58 -------
If by "delete this option from the C++ FE" you mean that `g++ -Winit-self
[...]' would give an error, I'm not sure that's the best approach if the option
is likely to be sorted out for C++ in the future. Removing it now will break
existing makefiles which use -Winit-self for C++ compilations. And once
-Winit-self is sorted out for C++, it will be harder to write a makefile which
gives a warning for self-initialised variables for any GCC version (if it's
left as-is for now, then -Winit-self can just be specified all the time for any
GCC version >= 3.4).
The situation here is slightly odd in that -Winit-self is effectively always on
for C++, so in a way it does work - it's not specifying it (or -Wno-init-self)
which doesn't!
I think it would be better to fix the documentation to reflect the current
behaviour for C++/ObjC++, and mark this bug as an enhancement request.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/34772] self-initialisation does not silence uninitialised warnings (-Winit-self ignored)
2008-01-13 18:24 [Bug c++/34772] New: -Winit-self ignored when compiling C++ (and ObjC++) olly at survex dot com
` (2 preceding siblings ...)
2008-01-14 1:36 ` olly at survex dot com
@ 2008-01-14 7:43 ` manu at gcc dot gnu dot org
2008-01-14 8:32 ` manu at gcc dot gnu dot org
` (10 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-01-14 7:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from manu at gcc dot gnu dot org 2008-01-14 01:27 -------
(In reply to comment #3)
> I think it would be better to fix the documentation to reflect the current
> behaviour for C++/ObjC++, and mark this bug as an enhancement request.
It is a bit misleading providing -Winit-self when it has no effect and when it
cannot be disabled. But your argument about breaking existing code is solid.
So, of course, I will only update the documentation:
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi (revision 130605)
+++ gcc/doc/invoke.texi (working copy)
@@ -2827,14 +2827,15 @@
@option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
can be disabled with the @option{-Wno-nonnull} option.
-@item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
+@item -Winit-self @r{(C and Objective-C only)}
@opindex Winit-self
Warn about uninitialized variables which are initialized with themselves.
Note this option can only be used with the @option{-Wuninitialized} option,
which in turn only works with @option{-O1} and above.
-For example, GCC will warn about @code{i} being uninitialized in the
-following snippet only when @option{-Winit-self} has been specified:
+For C and Objective-C, GCC will silence the warning about @code{i}
+being uninitialized in the following snippet unless
+@option{-Winit-self} has been specified:
@smallexample
@group
int f()
@@ -3094,11 +3095,12 @@
These warnings are possible only in optimizing compilation,
because they require data flow information that is computed only
when optimizing. If you do not specify @option{-O}, you will not get
-these warnings. Instead, GCC will issue a warning about
@option{-Wuninitialized}
-requiring @option{-O}.
+these warnings. Instead, GCC will issue a warning about
+@option{-Wuninitialized} requiring @option{-O}.
-If you want to warn about code which uses the uninitialized value of the
-variable in its own initializer, use the @option{-Winit-self} option.
+For C and Objective-C, using the uninitialized value of the variable in its
+own initializer (e.g. @samp{int i = i;}) silences the warning. If you
+want to warn about such code use the @option{-Winit-self} option.
These warnings occur for individual uninitialized or clobbered
elements of structure, union or array variables as well as for
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Summary|-Winit-self ignored when |self-initialisation does not
|compiling C++ (and ObjC++) |silence uninitialised
| |warnings (-Winit-self
| |ignored)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/34772] self-initialisation does not silence uninitialised warnings (-Winit-self ignored)
2008-01-13 18:24 [Bug c++/34772] New: -Winit-self ignored when compiling C++ (and ObjC++) olly at survex dot com
` (3 preceding siblings ...)
2008-01-14 7:43 ` [Bug c++/34772] self-initialisation does not silence uninitialised warnings (-Winit-self ignored) manu at gcc dot gnu dot org
@ 2008-01-14 8:32 ` manu at gcc dot gnu dot org
2008-01-14 8:59 ` pinskia at gcc dot gnu dot org
` (9 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-01-14 8:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from manu at gcc dot gnu dot org 2008-01-14 01:35 -------
Actually. Winit-self was introduced in GCC 3.4 but the init-self trick was
probably introduced earlier. So this may actually be a regression from much
earlier. Anyway, documenting that it doesn't work seems the right thing to do.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/34772] self-initialisation does not silence uninitialised warnings (-Winit-self ignored)
2008-01-13 18:24 [Bug c++/34772] New: -Winit-self ignored when compiling C++ (and ObjC++) olly at survex dot com
` (4 preceding siblings ...)
2008-01-14 8:32 ` manu at gcc dot gnu dot org
@ 2008-01-14 8:59 ` pinskia at gcc dot gnu dot org
2008-01-14 9:29 ` [Bug c++/34772] [3.4/4.0/4.1/4.2/4.3 Regression] " manu at gcc dot gnu dot org
` (8 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-01-14 8:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pinskia at gcc dot gnu dot org 2008-01-14 01:45 -------
This should work, if it does not then it is a bug.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/34772] [3.4/4.0/4.1/4.2/4.3 Regression] self-initialisation does not silence uninitialised warnings (-Winit-self ignored)
2008-01-13 18:24 [Bug c++/34772] New: -Winit-self ignored when compiling C++ (and ObjC++) olly at survex dot com
` (5 preceding siblings ...)
2008-01-14 8:59 ` pinskia at gcc dot gnu dot org
@ 2008-01-14 9:29 ` manu at gcc dot gnu dot org
2008-01-14 10:59 ` [Bug c++/34772] [4.1/4.2/4.3 " rguenth at gcc dot gnu dot org
` (7 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-01-14 9:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from manu at gcc dot gnu dot org 2008-01-14 02:08 -------
So it seems this worked in 3.3, so it is a regression after all.
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|enhancement |normal
Summary|self-initialisation does not|[3.4/4.0/4.1/4.2/4.3
|silence uninitialised |Regression] self-
|warnings (-Winit-self |initialisation does not
|ignored) |silence uninitialised
| |warnings (-Winit-self
| |ignored)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/34772] [4.1/4.2/4.3 Regression] self-initialisation does not silence uninitialised warnings (-Winit-self ignored)
2008-01-13 18:24 [Bug c++/34772] New: -Winit-self ignored when compiling C++ (and ObjC++) olly at survex dot com
` (6 preceding siblings ...)
2008-01-14 9:29 ` [Bug c++/34772] [3.4/4.0/4.1/4.2/4.3 Regression] " manu at gcc dot gnu dot org
@ 2008-01-14 10:59 ` rguenth at gcc dot gnu dot org
2008-01-20 7:02 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-14 10:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from rguenth at gcc dot gnu dot org 2008-01-14 10:46 -------
Regression for a GCC extension that silences a diagnostic. P4.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |3.3.6
Priority|P3 |P4
Summary|[3.4/4.0/4.1/4.2/4.3 |[4.1/4.2/4.3 Regression]
|Regression] self- |self-initialisation does not
|initialisation does not |silence uninitialised
|silence uninitialised |warnings (-Winit-self
|warnings (-Winit-self |ignored)
|ignored) |
Target Milestone|--- |4.1.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/34772] [4.1/4.2/4.3 Regression] self-initialisation does not silence uninitialised warnings (-Winit-self ignored)
2008-01-13 18:24 [Bug c++/34772] New: -Winit-self ignored when compiling C++ (and ObjC++) olly at survex dot com
` (7 preceding siblings ...)
2008-01-14 10:59 ` [Bug c++/34772] [4.1/4.2/4.3 " rguenth at gcc dot gnu dot org
@ 2008-01-20 7:02 ` pinskia at gcc dot gnu dot org
2008-07-04 22:28 ` [Bug c++/34772] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
` (5 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-01-20 7:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from pinskia at gcc dot gnu dot org 2008-01-20 05:39 -------
Tomorrow after my extra checking build finishes, I will look into fixing this
bug.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pinskia at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/34772] [4.2/4.3/4.4 Regression] self-initialisation does not silence uninitialised warnings (-Winit-self ignored)
2008-01-13 18:24 [Bug c++/34772] New: -Winit-self ignored when compiling C++ (and ObjC++) olly at survex dot com
` (8 preceding siblings ...)
2008-01-20 7:02 ` pinskia at gcc dot gnu dot org
@ 2008-07-04 22:28 ` jsm28 at gcc dot gnu dot org
2008-10-16 16:18 ` paolo dot carlini at oracle dot com
` (4 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-07-04 22:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from jsm28 at gcc dot gnu dot org 2008-07-04 22:28 -------
Closing 4.1 branch.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.1/4.2/4.3/4.4 Regression]|[4.2/4.3/4.4 Regression]
|self-initialisation does not|self-initialisation does not
|silence uninitialised |silence uninitialised
|warnings (-Winit-self |warnings (-Winit-self
|ignored) |ignored)
Target Milestone|4.1.3 |4.2.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/34772] [4.2/4.3/4.4 Regression] self-initialisation does not silence uninitialised warnings (-Winit-self ignored)
2008-01-13 18:24 [Bug c++/34772] New: -Winit-self ignored when compiling C++ (and ObjC++) olly at survex dot com
` (9 preceding siblings ...)
2008-07-04 22:28 ` [Bug c++/34772] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
@ 2008-10-16 16:18 ` paolo dot carlini at oracle dot com
2009-03-31 20:17 ` [Bug c++/34772] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
` (3 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-10-16 16:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from paolo dot carlini at oracle dot com 2008-10-16 16:16 -------
*** Bug 37854 has been marked as a duplicate of this bug. ***
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |julien dot sagnard at gmail
| |dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/34772] [4.3/4.4/4.5 Regression] self-initialisation does not silence uninitialised warnings (-Winit-self ignored)
2008-01-13 18:24 [Bug c++/34772] New: -Winit-self ignored when compiling C++ (and ObjC++) olly at survex dot com
` (10 preceding siblings ...)
2008-10-16 16:18 ` paolo dot carlini at oracle dot com
@ 2009-03-31 20:17 ` jsm28 at gcc dot gnu dot org
2009-08-04 12:48 ` rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-31 20:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from jsm28 at gcc dot gnu dot org 2009-03-31 20:17 -------
Closing 4.2 branch.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.2/4.3/4.4/4.5 Regression]|[4.3/4.4/4.5 Regression]
|self-initialisation does not|self-initialisation does not
|silence uninitialised |silence uninitialised
|warnings (-Winit-self |warnings (-Winit-self
|ignored) |ignored)
Target Milestone|4.2.5 |4.3.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/34772] [4.3/4.4/4.5 Regression] self-initialisation does not silence uninitialised warnings (-Winit-self ignored)
2008-01-13 18:24 [Bug c++/34772] New: -Winit-self ignored when compiling C++ (and ObjC++) olly at survex dot com
` (11 preceding siblings ...)
2009-03-31 20:17 ` [Bug c++/34772] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
@ 2009-08-04 12:48 ` rguenth at gcc dot gnu dot org
2009-12-30 11:29 ` manu at gcc dot gnu dot org
2010-05-22 18:21 ` [Bug c++/34772] [4.3/4.4/4.5/4.6 " rguenth at gcc dot gnu dot org
14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-08-04 12:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from rguenth at gcc dot gnu dot org 2009-08-04 12:28 -------
GCC 4.3.4 is being released, adjusting target milestone.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.3.4 |4.3.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/34772] [4.3/4.4/4.5 Regression] self-initialisation does not silence uninitialised warnings (-Winit-self ignored)
2008-01-13 18:24 [Bug c++/34772] New: -Winit-self ignored when compiling C++ (and ObjC++) olly at survex dot com
` (12 preceding siblings ...)
2009-08-04 12:48 ` rguenth at gcc dot gnu dot org
@ 2009-12-30 11:29 ` manu at gcc dot gnu dot org
2010-05-22 18:21 ` [Bug c++/34772] [4.3/4.4/4.5/4.6 " rguenth at gcc dot gnu dot org
14 siblings, 0 replies; 16+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-12-30 11:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #14 from manu at gcc dot gnu dot org 2009-12-30 11:29 -------
*** Bug 42238 has been marked as a duplicate of this bug. ***
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ext at sidvind dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/34772] [4.3/4.4/4.5/4.6 Regression] self-initialisation does not silence uninitialised warnings (-Winit-self ignored)
2008-01-13 18:24 [Bug c++/34772] New: -Winit-self ignored when compiling C++ (and ObjC++) olly at survex dot com
` (13 preceding siblings ...)
2009-12-30 11:29 ` manu at gcc dot gnu dot org
@ 2010-05-22 18:21 ` rguenth at gcc dot gnu dot org
14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-05-22 18:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #15 from rguenth at gcc dot gnu dot org 2010-05-22 18:11 -------
GCC 4.3.5 is being released, adjusting target milestone.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.3.5 |4.3.6
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772
^ permalink raw reply [flat|nested] 16+ messages in thread