[LLVMdev] some undefined behaviors in llvm/clang

John Regehr regehr at cs.utah.edu
Thu Jul 22 21:56:07 PDT 2010


Hi folks,

Below is a short list of integer undefined behaviors executed by Clang
when compiling the LLVM test suite.  They seem pretty self explanatory,
but let me know if not, if you cannot reproduce any of them, or if it
would be better for me to file bugzillas on them.  This is on x64 Linux,
using r108984.



Thanks,





John





---------------------------------





CLANG UNDEFINED at <BitcodeWriter.cpp, (740:29)> : Op: -, Reason :
Signed Subtraction Overflow, left (int64): 0 right (int64):
-9223372036854775808

Command causing this error:



clang
-I/uusoc/exports/scratch/regehr/z/llvm-2/projects/test-suite/SingleSource/Regression/C
-I/uusoc/exports/scratch/regehr/z/llvm-2/projects/test-suite/SingleSource/Regression/C
-I/home/regehr/z/llvm-2/include
-I/home/regehr/z/llvm-2/projects/test-suite/include -I../../../include
-I/home/regehr/z/llvm-2/include -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
-DNDEBUG  -O3 -mllvm -disable-llvm-optzns  -m64 -fomit-frame-pointer -c
casts.c -o Output/casts.bc -emit-llvm

---------------------------------

CLANG UNDEFINED at <InitPreprocessor.cpp, (173:39)> : Op: -, Reason :
Signed Subtraction Overflow, left (int64): -9223372036854775808 right
(int64): 1

Command causing this error:

RunToolSafely.sh 500 clang Output/sse.expandfft.cbe.c -o
Output/sse.expandfft.cbe -lm -O3 -fno-strict-aliasing -fno-inline -msse2
-m64 -fomit-frame-pointer

---------------------------------

CLANG UNDEFINED at <InstCombineCalls.cpp, (105:23)> : Op: <<, Reason :
Unsigned Left Shift Error: Right operand is negative or is greater than
or equal to the width of the promoted left operand, left (uint32): 1
right (uint32): 63

Command causing this error:

clang
-I/uusoc/exports/scratch/regehr/z/llvm-2/projects/test-suite/MultiSource/Benchmarks/VersaBench/dbms
-I/uusoc/exports/scratch/regehr/z/llvm-2/projects/test-suite/MultiSource/Benchmarks/VersaBench/dbms
-I/home/regehr/z/llvm-2/include
-I/home/regehr/z/llvm-2/projects/test-suite/include
-I../../../../include -I/home/regehr/z/llvm-2/include -D_GNU_SOURCE
-D__STDC_LIMIT_MACROS -DNDEBUG  -O3  -c volume.c -o Output/volume.o

---------------------------------

CLANG UNDEFINED at <TargetData.cpp, (629:28)> : Op: *, Reason : Signed
Multiplication Overflow, left (int64): 142998016075267841 right (int64):
129

Command causing this error:

clang
-I/uusoc/exports/scratch/regehr/z/llvm-2/projects/test-suite/MultiSource/Benchmarks/Prolangs-C/assembler
-I/uusoc/exports/scratch/regehr/z/llvm-2/projects/test-suite/MultiSource/Benchmarks/Prolangs-C/assembler
-I/home/regehr/z/llvm-2/include
-I/home/regehr/z/llvm-2/projects/test-suite/include
-I../../../../include -I/home/regehr/z/llvm-2/include -D_GNU_SOURCE
-D__STDC_LIMIT_MACROS -DNDEBUG  -O3  -c scan_line.c -o Output/scan_line.o

---------------------------------

CLANG UNDEFINED at
</uusoc/exports/scratch/regehr/z/llvm-2/include/llvm/Instructions.h,
(233:15)> : Op: <<, Reason : Signed Left Shift Error: Right operand is
negative or is greater than or equal to the width of the promoted left
operand, left (int32): 1 right (int32): 32

Command causing this error:

clang
-I/uusoc/exports/scratch/regehr/z/llvm-2/projects/test-suite/MultiSource/Benchmarks/VersaBench/dbms
-I/uusoc/exports/scratch/regehr/z/llvm-2/projects/test-suite/MultiSource/Benchmarks/VersaBench/dbms
-I/home/regehr/z/llvm-2/include
-I/home/regehr/z/llvm-2/projects/test-suite/include
-I../../../../include -I/home/regehr/z/llvm-2/include -D_GNU_SOURCE
-D__STDC_LIMIT_MACROS -DNDEBUG  -O3  -c volume.c -o Output/volume.o

---------------------------------



More information about the llvm-dev mailing list