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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
             Blocks|                            |24639

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
The interesting thing is that enabling the middle-end diagnostic to trigger
shows we emit duplicate diagnostics:

struct Camera {
    float clip_area;
    float border = 10.f;
    [[gnu::noinline]] Camera() : clip_area(border) { }
};

Camera foo()
{
  Camera c;
  return c;
}

emits

t.C: In constructor 'Camera::Camera()':
t.C:4:44: warning: member 'Camera::border' is used uninitialized
[-Wuninitialized]
    4 |     [[gnu::noinline]] Camera() : clip_area(border) { }
      |                                            ^~~~~~
t.C: In constructor 'Camera::Camera()':
t.C:4:44: warning: '*this.Camera::border' is used uninitialized
[-Wuninitialize]
    4 |     [[gnu::noinline]] Camera() : clip_area(border) { }
      |                                            ^~~~~~

the first is from the C++ FE find_uninit_fields diagnostic which for some
reason doesn't work for the testcase in the description, possibly
the initializer list(?) isn't handled?  The early uninit IL is

  <bb 2> :
  MEM[(struct __as_base  &)this_6(D)] ={v} {CLOBBER};
  _1 = &this_6(D)->clip_area;
  std::allocator<Camera::P2d>::allocator (&D.26049);
  _2 = this_6(D)->border;
  D.26047[0].x = _2;
  _3 = this_6(D)->border;
  D.26047[0].y = _3;
  D.27007._M_array = &D.26047;
  D.27007._M_len = 1;
  std::vector<Camera::P2d>::vector (_1, D.27007, &D.26049);

the call to std::allocator<Camera::P2d>::allocator is thought to clobber
*this and thus possibly initialize 'border' here.

I'm testing a middle-end fix here - Marek, can you see whether it's possible
to detect this in the frontend?  The middle-end will require optimization.
The duplicate diagnostic might also be interesting to look at, but that
might already be reported separately?


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