https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83468

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-12-19
             Blocks|                            |24639
     Ever confirmed|0                           |1

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
The main issue is that the early uninit pass doesn't see enough because no
inlining was performed yet and the late uninit pass sees at -O2 just

int main(int, const char**) (int argc, const char * * argv)
{
  double q;
  struct __ostream_type & _3;
  struct __ostream_type & _4;

  <bb 2> [100.00%]:
  operator new (1);
  _3 = std::basic_ostream<char>::_M_insert<double> (&cout, q_9(D));
  std::endl<char, std::char_traits<char> > (_3);
  _4 = std::basic_ostream<char>::_M_insert<double> (&cout, 4.2e+1);
  std::endl<char, std::char_traits<char> > (_4);
  return 0;

where it could warn about the use of q_9(D) but its location is the call to
_M_insert which is hidden behind the -Wsystem-headers paywall.  For me
it warns at -O[12] -Wall -Wsystem-headers:

> g++-7 -S t.C -Wall -O2 -fdump-tree-all -Wsystem-headers
In file included from /usr/include/c++/7/iostream:39:0,
                 from t.C:1:
/usr/include/c++/7/ostream: In function ‘int main(int, const char**)’:
/usr/include/c++/7/ostream:221:29: warning: ‘q’ is used uninitialized in this
function [-Wuninitialized]
       { return _M_insert(__f); }
                             ^
t.C:11:10: note: ‘q’ was declared here
   double q;
          ^

note C++ absolutely requires abstraction removal for this kind of warning
so it isn't effective at -O0.  Improved locations on GIMPLE similar to what
David proposes in the FEs might help here.

What also might help is moving (duplicating?) the early uninit pass after
early inlining.  There we see:

int main(int, const char**) (int argc, const char * * argv)
{
  struct klass * ptr;
  double q;
  double q.0_1;
  double q.1_2;
  void * _6;
  void * _7;
  int _13;
  struct __ostream_type & _15;
  struct __ostream_type & _16;

  <bb 2> [0.00%]:
  [t.C:13:19] _6 = operator new (1);

  <bb 3> [100.00%]:
  [t.C:13:19] _7 = _6;
  [t.C:13:7] ptr_8 = _7;
  [t.C:14:13] q.0_1 = q_22(D);
  [/usr/include/c++/7/ostream:221:29] _15 =
std::basic_ostream<char>::_M_insert<double> ([t.C:5:44] &cout, q.0_1);


Referenced Bugs:

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

Reply via email to