public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48829] New: g++ no warning initializing a variable using itself
@ 2011-04-29 22:09 mfribeiro at gmail dot com
  2011-04-30 19:52 ` [Bug c++/48829] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: mfribeiro at gmail dot com @ 2011-04-29 22:09 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: g++ no warning initializing a variable using itself
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mfribeiro@gmail.com


This code issues a warning:

g++ -Wall
int i = 5 + i;
warning: ‘i’ may be used uninitialized in this function

This code does not:
string s = string("str") + s;

Neither this:
string s(string("str") + s);

Shouldnt the 2 last ones issue warnings too?


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

* [Bug c++/48829] g++ no warning initializing a variable using itself
  2011-04-29 22:09 [Bug c++/48829] New: g++ no warning initializing a variable using itself mfribeiro at gmail dot com
@ 2011-04-30 19:52 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2011-04-30 19:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-04-30 19:52:08 UTC ---
The string case calls a function (the overloaded operator+ or std::string) so
is actually closer to:

  int f(int);
  int i = f(i);

which doesn't warn either (although it should do, ideally)

This is similar to PR 48483, maybe even a dup.


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

end of thread, other threads:[~2011-04-30 19:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-29 22:09 [Bug c++/48829] New: g++ no warning initializing a variable using itself mfribeiro at gmail dot com
2011-04-30 19:52 ` [Bug c++/48829] " redi 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).