This is the mail archive of the gcc-patches@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]

PR34772: document that Winit-self is pointless in C++/ObjC++


From PR34772, it seems the init-self trick to avoid uninitialised
warnings never worked in C++. Or at least it didn't work in GCC 3.4
when Winit-self was introduced. So let's document this.

2008-01-14  Manuel López-Ibáñez  <manu@gcc.gnu.org>

 PR c++/34772
 * doc/invoke.tex (Winit-self): Only for C and ObjC.
   (Wuninitialized): mention that self-initialization does not silence
warnings in C++ and ObjectiveC++.
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

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