[cfe-dev] clang bug? Miscompilation of array of unsigned long long

Edward Meewis ed at extraordinarymachine.nl
Sun Aug 1 07:52:07 PDT 2010


  On 31-07-10 1:20, Eli Friedman wrote:
> Could you attach the generated .o file with and without the --32 option?
> -Eli

Turns out the --32 doesn't matter.

However, my system has two versions of binutils and gcc uses the one 
delivered with FreeBSD-8.0 and clang uses the one installed through 
ports. clang somehow produces asm that the newer version of as doesn't 
like. gcc produces something that works correctly in both cases:

old as: /usr/bin/as --version
GNU assembler 2.15 [FreeBSD] 2004-05-23
Copyright 2002 Free Software Foundation, Inc.

new as: /usr/local/bin/as --version
GNU assembler (GNU Binutils) 2.20.1.20100303

clang direct:
clang -o arrTest-clang arrTest.c
./arrTest-clang
FFFFFFFD00000000, 18446744060824649728
0000FFFD00000000, 0281462091808768

gcc direct:
gcc -o arrTest-gcc arrTest.c
./arrTest-gcc
FFFFFFFD00000000, 18446744060824649728
FFFFFFFD00000000, 18446744060824649728

LINKOPTS="--eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 -m 
elf_i386_fbsd   /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o 
-lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s 
--no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o"

clang asm with old as:
clang -o arrTest-clang.asm -S arrTest.c
/usr/bin/ld -o arrTest-clang-oldas arrTest-clang-oldas.o ${LINKOPTS}
./arrTest-clang-oldas
FFFFFFFD00000000, 18446744060824649728
FFFFFFFD00000000, 18446744060824649728

clang asm with new as:
/usr/local/bin/as -o arrTest-clang-newas.o arrTest-clang.asm
/usr/local/bin/ld -o arrTest-clang-newas arrTest-clang-newas.o ${LINKOPTS}
./arrTest-clang-newas
FFFFFFFD00000000, 18446744060824649728
0000FFFD00000000, 0281462091808768

gcc asm with old as:
gcc -o arrTest-gcc.asm -S arrTest.c
/usr/bin/as -o arrTest-gcc-oldas.o arrTest-gcc.asm
/usr/bin/ld \-o arrTest-gcc-oldas arrTest-gcc-oldas.o ${LINKOPTS}
./arrTest-gcc-oldas
FFFFFFFD00000000, 18446744060824649728
FFFFFFFD00000000, 18446744060824649728

gcc asm with new as:
gcc -o arrTest-gcc.asm -S arrTest.c
/usr/bin/as -o arrTest-gcc-newas.o arrTest-gcc.asm
/usr/bin/ld -o arrTest-gcc-newas arrTest-gcc-newas.o ${LINKOPTS}
./arrTest-gcc-newas
FFFFFFFD00000000, 18446744060824649728
FFFFFFFD00000000, 18446744060824649728

Weird. Any ideas what's going on? I've attached test script, source file 
and both asm's.

Is there a way to force which assembler the clang driver is using?

-- Ed.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: arrTest.c
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100801/1c55fabc/attachment.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: arrTest-clang.asm
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100801/1c55fabc/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: arrTest-gcc.asm
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100801/1c55fabc/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.sh
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100801/1c55fabc/attachment-0002.ksh>


More information about the cfe-dev mailing list