[Bug c++/111123] Warning about "used uninitialized" member shown or hidden randomly

2023-08-24 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23

Richard Biener  changed:

   What|Removed |Added

   Assignee|rguenth at gcc dot gnu.org |unassigned at gcc dot 
gnu.org
 Status|ASSIGNED|NEW

--- Comment #6 from Richard Biener  ---
middle-end part are fixed, so with optimization we should diagnose this more
consistently now.  Leaving open for -O0 and the C++ FE issue.

[Bug c++/111123] Warning about "used uninitialized" member shown or hidden randomly

2023-08-24 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23

--- Comment #5 from CVS Commits  ---
The master branch has been updated by Richard Biener :

https://gcc.gnu.org/g:abf915193fbf725bb359e6936e10dcc282eb94cc

commit r14-3460-gabf915193fbf725bb359e6936e10dcc282eb94cc
Author: Richard Biener 
Date:   Thu Aug 24 09:32:54 2023 +0200

tree-optimization/23 - indirect clobbers thrown away too early

The testcase in the PR shows that late uninit diagnostic relies
on indirect clobbers in CTORs but we throw those away in the fab
pass which is too early.  The reasoning was they were supposed
to keep SSA names live but that's no longer the case since DCE
doesn't treat them as keeping SSA uses live.

The following instead removes them before out-of-SSA coalescing
which is the thing that's still affected by them.

PR tree-optimization/23
* tree-ssa-ccp.cc (pass_fold_builtins::execute): Do not
remove indirect clobbers here ...
* tree-outof-ssa.cc (rewrite_out_of_ssa): ... but here.
(remove_indirect_clobbers): New function.

* g++.dg/warn/Wuninitialized-pr23-1.C: New testcase.

[Bug c++/111123] Warning about "used uninitialized" member shown or hidden randomly

2023-08-24 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23

Richard Biener  changed:

   What|Removed |Added

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

--- Comment #4 from Richard Biener  ---
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

   :
  MEM[(struct __as_base  &)this_6(D)] ={v} {CLOBBER};
  _1 = _6(D)->clip_area;
  std::allocator::allocator ();
  _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.27007._M_len = 1;
  std::vector::vector (_1, D.27007, );

the call to std::allocator::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

[Bug c++/111123] Warning about "used uninitialized" member shown or hidden randomly

2023-08-24 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23

--- Comment #3 from Richard Biener  ---
Adding [[gnu::noinline]] to Camera::Camera will never warn.

[Bug c++/111123] Warning about "used uninitialized" member shown or hidden randomly

2023-08-24 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23

Richard Biener  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Last reconfirmed||2023-08-24
 Status|UNCONFIRMED |ASSIGNED
   Keywords||diagnostic
   Assignee|unassigned at gcc dot gnu.org  |rguenth at gcc dot 
gnu.org

--- Comment #2 from Richard Biener  ---
There's a change in inlining when z is removed.  We then have the separate CTOR

void Camera::Camera (struct Camera * const this)
{
...
  [local count: 1073741824]:
  _2 = *this_6(D).border;
  _3 = 1.0e+0 - _2;
  _68 = {_2, _2, _3, _2};

and fno CLOBBER of *this_6(D) at its start at the time we do late uninit
diagnostics.  That's because we remove those indirect clobbers too early.

[Bug c++/111123] Warning about "used uninitialized" member shown or hidden randomly

2023-08-23 Thread agriff at tin dot it via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23

--- Comment #1 from Andrea Griffini  ---
Forgot to say that -O3 is needed to see the warning (this is however expected)