This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/34772] self-initialisation does not silence uninitialised warnings (-Winit-self ignored)



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]