public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/50590] New: Initializing a variable to itself yields garbage/UB and no warning.
@ 2011-10-02 16:27 eyal.lotem at gmail dot com
  2011-10-02 16:43 ` [Bug c/50590] " schwab@linux-m68k.org
  0 siblings, 1 reply; 2+ messages in thread
From: eyal.lotem at gmail dot com @ 2011-10-02 16:27 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50590
           Summary: Initializing a variable to itself yields garbage/UB
                    and no warning.
    Classification: Unclassified
           Product: gcc
           Version: 4.5.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: eyal.lotem@gmail.com


Exact version string:

gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2

This is very similar to: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10538

But weirdly, while:

    int x = x + 1;

Does yield a warning, this:

    int x = x;

does not.

This may accidentally happen in e.g macros:

    #define F(_x) \
       int _x = x;
       ... use _x ...

expands to:

       int x = x;
       use x;


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

* [Bug c/50590] Initializing a variable to itself yields garbage/UB and no warning.
  2011-10-02 16:27 [Bug c/50590] New: Initializing a variable to itself yields garbage/UB and no warning eyal.lotem at gmail dot com
@ 2011-10-02 16:43 ` schwab@linux-m68k.org
  0 siblings, 0 replies; 2+ messages in thread
From: schwab@linux-m68k.org @ 2011-10-02 16:43 UTC (permalink / raw)
  To: gcc-bugs

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

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> 2011-10-02 16:43:09 UTC ---
This is a feature, use -Winit-self.


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

end of thread, other threads:[~2011-10-02 16:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-02 16:27 [Bug c/50590] New: Initializing a variable to itself yields garbage/UB and no warning eyal.lotem at gmail dot com
2011-10-02 16:43 ` [Bug c/50590] " schwab@linux-m68k.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).