This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/61520] False warning: array subscript is below array bounds (-Warray-bounds -O -ftree-vrp -funroll-loops)
- From: "vuvova at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 17 Jun 2014 15:42:56 +0000
- Subject: [Bug c/61520] False warning: array subscript is below array bounds (-Warray-bounds -O -ftree-vrp -funroll-loops)
- Auto-submitted: auto-generated
- References: <bug-61520-4 at http dot gcc dot gnu dot org/bugzilla/>
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