[Bug tree-optimization/92879] [10 Regression] incorrect warning of __builtin_memset offset is out of the bounds on zero-size allocation and initialization

2020-03-09 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92879

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #6 from Jakub Jelinek  ---
The placement new is inlined at this point, the operator new that remains is
replaceable and because a is a global variable, its address needs to be
considered escaped.
While access to not yet fully constructed var from another TU might be
problematic, in what the restrict pass we actually don't know (unless we look
at abstract origin and prove there is no post-ctor code in between) it is a
ctor which would have such restrictions.

[Bug tree-optimization/92879] [10 Regression] incorrect warning of __builtin_memset offset is out of the bounds on zero-size allocation and initialization

2020-02-02 Thread law at redhat dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92879

Jeffrey A. Law  changed:

   What|Removed |Added

   Priority|P3  |P2
 CC||law at redhat dot com

[Bug tree-optimization/92879] [10 Regression] incorrect warning of __builtin_memset offset is out of the bounds on zero-size allocation and initialization

2020-01-17 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92879

Richard Biener  changed:

   What|Removed |Added

   Keywords||missed-optimization
 CC||rguenth at gcc dot gnu.org

--- Comment #5 from Richard Biener  ---
There's eventually the possibility to adjust call_may_clobber_ref_p_1 to
handle calls that are DECL_IS_REPLACEABLE_OPERATOR_NEW_P specially.
Not sure why that is "replaceable" but you mention
new is not replaceable...  Ah, there's also DECL_IS_OPERATOR_NEW_P
(but docs say it's to be used for alias analysis on the resulting ptr).

[Bug tree-optimization/92879] [10 Regression] incorrect warning of __builtin_memset offset is out of the bounds on zero-size allocation and initialization

2019-12-10 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92879

--- Comment #4 from Martin Sebor  ---
After some more thought I think I need to correct myself: I suppose even in a
ctor the this pointer might need to be treated as having escaped and be
accessible to a replacement operator new, but placement new is not replaceable
so it can't access such an escaped pointer.

[Bug tree-optimization/92879] [10 Regression] incorrect warning of __builtin_memset offset is out of the bounds on zero-size allocation and initialization

2019-12-10 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92879

Martin Sebor  changed:

   What|Removed |Added

   Keywords||alias
 Blocks||56456

--- Comment #3 from Martin Sebor  ---
The warning sees the IL below so it's doing the right thing.  GCC doesn't
"know" that operator new doesn't clobber this->m so it doesn't eliminate the
for loop.  Rewriting the loop like so avoids the warning and results in optimal
code equivalent to that emitted by Clang:

for(int j=0;j [local count: 1073741824]:
  MEM[(struct  &)&a] ={v} {CLOBBER};
  a.m = 0;
  _5 = operator new [] (0);
  a.p = _5;
  _2 = a.m; <<< unnecessary: _2 must be 0
  if (_2 <= 0)
goto ; [11.00%]
  else
goto ; [89.00%]

   [local count: 955630224]:
  _20 = (unsigned int) _2;
  _12 = _20 + 4294967295;
  _6 = (sizetype) _12;
  _21 = (sizetype) _2;
  _7 = _21 * 4;
  __builtin_memset (_5, 0, _7);

   [local count: 1073741833]:
  return;

}


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56456
[Bug 56456] [meta-bug] bogus/missing -Warray-bounds

[Bug tree-optimization/92879] [10 Regression] incorrect warning of __builtin_memset offset is out of the bounds on zero-size allocation and initialization

2019-12-10 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92879

Martin Liška  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-12-10
 CC||marxin at gcc dot gnu.org,
   ||msebor at gcc dot gnu.org
  Known to work||9.2.0
   Target Milestone|--- |10.0
Summary|incorrect warning of|[10 Regression] incorrect
   |__builtin_memset offset is  |warning of __builtin_memset
   |out of the bounds on|offset is out of the bounds
   |zero-size allocation and|on zero-size allocation and
   |initialization  |initialization
 Ever confirmed|0   |1
  Known to fail||10.0

--- Comment #2 from Martin Liška  ---
Confirmed, started with r278983.