[Bug c/61520] False warning: array subscript is below array bounds (-Warray-bounds -O -ftree-vrp -funroll-loops)

vuvova at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Jun 17 15:43:00 GMT 2014


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

--- Comment #1 from Sergei Golubchik <vuvova at gmail dot com> ---
A slightly modified version:

  static const int powers10[]= { 0, 1, 10, 100 };
  int remove_leading_zeroes(unsigned int decimals, unsigned int var)
  {
    decimals%= 2;
    while (var < powers10[decimals--]) ;
    return decimals;
  }

assembly:

remove_leading_zeroes:
        andl    $1, %edi
        movl    %edi, %edx
        leal    -1(%rdi), %eax
        cmpl    powers10(,%rdx,4), %esi
        jae     .L2
        movl    %eax, %ecx
        leal    -2(%rdi), %edx
        cmpl    powers10(,%rcx,4), %esi
        movl    %edx, %eax
        jae     .L2
        leal    -3(%rdi), %eax
        subl    $4, %edi
        cmpl    powers10(,%rdx,4), %esi
        cmovb   %edi, %eax
.L2:
        rep ret



More information about the Gcc-bugs mailing list