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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
   Target Milestone|---                         |7.2
            Summary|Warning with std::vector    |[7/8 Regression] Warning
                   |resize in loop              |with std::vector resize in
                   |                            |loop

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
The warning could be improved to print the size signed or say that a negative
number passed as size is likely the reason.

It looks like the memset call is produced by loop distribution:

   <bb 11> [9.15%]:
-
-  <bb 12> [51.85%]:
-  # __niter_77 = PHI <__niter_59(13), 18446744073709551615(11)>
-  # __first_61 = PHI <__first_60(13), c$D15833$_M_impl$_M_finish_68(11)>
-  *__first_61 = 0;
-  __niter_59 = __niter_77 + 18446744073709551615;
-  __first_60 = __first_61 + 4;
-  if (__niter_59 == 0)
-    goto <bb 5>; [17.65%]
-  else
-    goto <bb 13>; [82.35%]
-
-  <bb 13> [42.70%]:
-  goto <bb 12>; [100.00%]
+  __builtin_memset (c$D15833$_M_impl$_M_finish_68, 0, 18446744073709551612);
+  goto <bb 5>; [17.65%]

where the loop iterates { -1, +, -1 } thus quite a bit...  This is all
guarded by an overflow check it seems:

  <bb 9> [85.56%]:
  sz_13 = _17 + 18446744073709551615;
  if (sz_13 > _17)
    goto <bb 10>; [29.56%]
  else
    goto <bb 15>; [70.44%]

so maybe libstdc++ could avoid this bogus loop.

Reply via email to