[Bug c/69381] New: Maximum long loop completes immediately

2016-01-20 Thread alexander.gantman at intel dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69381

Bug ID: 69381
   Summary: Maximum long loop completes immediately
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: alexander.gantman at intel dot com
  Target Milestone: ---

The case (taken from U_BOOT code)

size_t strnlen(const char * s, size_t count)  
{
const char *sc;

for (sc = s; count-- && *sc != '\0'; ++sc)
/* nothing */;
return sc - s;
}

int main()
{
signed int prec = -1;
size_t res=0;
char* str = "mordy";
res = strnlen(str, prec);
}

Expectation res = 5;
Actual Result res = 0;


gcc line:

home/shaharmo/bin/ext_toolchain/bin/arc-linux-uclibc-gcc -Wp,-MD,post/.post.o.d
 -nostdinc -isystem
/home/shaharmo/bin/ext_toolchain/bin/../lib/gcc/arc-snps-linux-ucl
ibc/4.8.4/include -Iinclude   -I./arch/arc/include -include
./include/linux/kconfig.h -D__KERNEL__ -D__UBOOT__
-DCONFIG_SYS_TEXT_BASE=0xE010 -Wall -Wstrict-prototypes -Wno-format-sec
urity -fno-builtin -ffreestanding -Os -fno-stack-protector
-fno-delete-null-pointer-checks -g -fstack-usage -Wno-format-nonliteral
-mlittle-endian -marchs -ffixed-r25 -D__ARC__ -gdwarf-2
-pipe-D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(post)" 
-D"KBUILD_MODNAME=KBUILD_STR(post)" -c -o post/post.o post/post.c


Gcc build

Using built-in specs.
COLLECT_GCC=/home/shaharmo/bin/ext_toolchain/bin/arc-linux-uclibc-gcc
COLLECT_LTO_WRAPPER=/home/shaharmo/bin/ext_toolchain/bin/../libexec/gcc/arc-snps-linux-uclibc/4.8.4/lto-wrapper
Target: arc-snps-linux-uclibc
Configured with: /home/akolesov/ws/arc-2015.06-rc2/gcc/configure
--target=arc-snps-linux-uclibc --with-cpu=archs --disable-multilib
--with-pkgversion='ARCv2 ISA Linux uClibc toolchain 2015.06'
--with-bugurl=https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/issues
--enable-fast-install=N/A --with-endian=little --disable-werror
--enable-languages=c,c++
--prefix=/home/akolesov/ws/arc-2015.06-rc2/toolchain/../release_output/arc_gnu_2015.06_prebuilt_uclibc_le_archs_linux_install
--enable-shared --without-newlib --disable-libgomp --with-python=no
LDFLAGS=-static
--with-sysroot=/home/akolesov/ws/arc-2015.06-rc2/toolchain/../release_output/arc_gnu_2015.06_prebuilt_uclibc_le_archs_linux_install/arc-snps-linux-uclibc/sysroot
Thread model: posix
gcc version 4.8.4 (ARCv2 ISA Linux uClibc toolchain 2015.06)

[Bug target/69381] Maximum long loop completes immediately

2016-01-20 Thread alexander.gantman at intel dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69381

--- Comment #2 from Alexander Gantman  ---
We also had checked it on x86 and it was ok.The problem is only on ARC.
more over it works fine with Arc Compiler. Only GCC generates wrong assembly.