[Bug c++/48829] g++ no warning initializing a variable using itself

2011-04-30 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48829

--- Comment #1 from Jonathan Wakely  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.


[Bug c++/48829] g++ no warning initializing a variable using itself

2017-08-18 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48829

Eric Gallager  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-08-18
 CC||egallager at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #2 from Eric Gallager  ---
(In reply to matferib from comment #0)
> 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?

(In reply to Jonathan Wakely from comment #1)
> 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.

So, I combined all the snippets into a single testcase, and g++ doesn't even
warn on the first one anymore:

$ cat 48829.cc
#include 

using namespace std;

int i = 5 + i;

string s = string("str") + s;

string ss(string("str") + ss);

int f(int);
int ii = f(ii);
$ /usr/local/bin/g++ -c -Wall -Wextra -pedantic -Wuninitialized -Winit-self
-Weffc++ -O2 48829.cc
$ 

Same with all other optimization levels I tried. So, confirmed.

[Bug c++/48829] g++ no warning initializing a variable using itself

2019-11-21 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48829

Eric Gallager  changed:

   What|Removed |Added

 CC||redi at gcc dot gnu.org
 Blocks||24639

--- Comment #6 from Eric Gallager  ---
(In reply to Jonathan Wakely from comment #4)
> I would expect the expression 5 + i to give a -Wuninitialized warning.

ok, making this block the -Wuninitialized meta-bug then


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
[Bug 24639] [meta-bug] bug to track all Wuninitialized issues

[Bug c++/48829] g++ no warning initializing a variable using itself

2018-11-20 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48829

--- Comment #3 from Eric Gallager  ---
Is the expectation here for the warning to come from -Wuninitialized,
-Winit-self, or some other flag?

[Bug c++/48829] g++ no warning initializing a variable using itself

2018-11-21 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48829

--- Comment #4 from Jonathan Wakely  ---
I would expect the expression 5 + i to give a -Wuninitialized warning.

[Bug c++/48829] g++ no warning initializing a variable using itself

2018-11-21 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48829

--- Comment #5 from Jonathan Wakely  ---
Well, that one already does. So I'd expect std::string("str") + s and f(i) to
do so as well.