public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53287] New: "self-initialization" warning doesn't seem to work for non-primitive types...
@ 2012-05-09  0:04 miles at gnu dot org
  2012-05-09 10:53 ` [Bug c++/53287] " manu at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: miles at gnu dot org @ 2012-05-09  0:04 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: miles@gnu.org


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/53287] "self-initialization" warning doesn't seem to work for non-primitive types...
  2012-05-09  0:04 [Bug c++/53287] New: "self-initialization" warning doesn't seem to work for non-primitive types miles at gnu dot org
@ 2012-05-09 10:53 ` manu at gcc dot gnu.org
  2012-05-09 15:59 ` redi at gcc dot gnu.org
  2012-10-25  9:15 ` manu at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: manu at gcc dot gnu.org @ 2012-05-09 10:53 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53287

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-05-09
                 CC|                            |manu at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-05-09 10:51:44 UTC ---
For sure this is a bug. What is the correct behaviour is not so clear.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/53287] "self-initialization" warning doesn't seem to work for non-primitive types...
  2012-05-09  0:04 [Bug c++/53287] New: "self-initialization" warning doesn't seem to work for non-primitive types miles at gnu dot org
  2012-05-09 10:53 ` [Bug c++/53287] " manu at gcc dot gnu.org
@ 2012-05-09 15:59 ` redi at gcc dot gnu.org
  2012-10-25  9:15 ` manu at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2012-05-09 15:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53287

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-09 15:56:15 UTC ---
I'm pretty sure this is a dup - it's at least discussed in another bug I've
commented on, w.r.t self-init of a std::string


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/53287] "self-initialization" warning doesn't seem to work for non-primitive types...
  2012-05-09  0:04 [Bug c++/53287] New: "self-initialization" warning doesn't seem to work for non-primitive types miles at gnu dot org
  2012-05-09 10:53 ` [Bug c++/53287] " manu at gcc dot gnu.org
  2012-05-09 15:59 ` redi at gcc dot gnu.org
@ 2012-10-25  9:15 ` manu at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: manu at gcc dot gnu.org @ 2012-10-25  9:15 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53287

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-25 09:15:35 UTC ---
Dup

*** This bug has been marked as a duplicate of bug 52167 ***


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-10-25  9:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-09  0:04 [Bug c++/53287] New: "self-initialization" warning doesn't seem to work for non-primitive types miles at gnu dot org
2012-05-09 10:53 ` [Bug c++/53287] " manu at gcc dot gnu.org
2012-05-09 15:59 ` redi at gcc dot gnu.org
2012-10-25  9:15 ` manu at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).