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

--- Comment #13 from Martin Sebor <msebor at gcc dot gnu.org> ---
There is a call to malloc(SIZE_MAX - 15) in GIMPLE, as a result of the
conditional and I believe jump threading.  Just after thread1 we see this in
the vrp1 dump:

  <bb 20> [local count: 32272892]:
  # _91 = PHI <_54(4), _6(6)>
  # iftmp.2_92 = PHI <1152921504606846975(4), 1152921504606846975(6)>
  size_94 = iftmp.2_92 * 16;
  result_96 = __builtin_malloc (size_94);
  goto <bb 9>; [100.00%]

and after cselim:

  <bb 20> [local count: 32272892]:
  # _91 = PHI <_54(4), _6(6)>
  size_94 = 18446744073709551600;
  result_96 = __builtin_malloc (size_94);
  goto <bb 9>; [100.00%]

which is then propagated into malloc.  That's what the warning sees.

I think the malloc folding would be fine (provided errno was set as well) but
operator new probably wouldn't be because the operator is replaceable so it
could be detected (unless the standard was changed to allow the elision).

Reply via email to