http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53287
Bug #: 53287
Summary: "self-initialization" warning doesn't seem to work for
non-primitive types...
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
Gcc has a warning "-Winit-self" which is supposed to warn about cases like "int
x = x;"
It seems to work properly for primitive types, but emits no warnings for
classes.
E.g., the following:
struct S { S (); S (const S &); int i; };
extern void g (const S &);
void f ()
{
S x = x;
g (x);
}
compiles without warnings:
$ g++-snapshot -c x.cc -O2 -Wall -Wextra -Winit-self
$ g++-snapshot --version
g++ (Debian 20120501-1) 4.8.0 20120501 (experimental) [trunk revision
187013]
Replacing the definition of "S" with "typedef int S;", results in the expected
warning: "warning: 'x' is used uninitialized in this function
[-Wuninitialized]", although the warning-flag referenced in the message
("-Wuninitialized") seems a bit odd, as it's clearly -Winit-self that controls
this -- removing -Winit-self from the command-line (but keeping -Wall and
-Wextra) eliminates the warning...
Thanks,
-miles