Open bi6c opened 4 months ago
Could you please try 18 or main
branch? https://godbolt.org should be helpful.
Could you please try 18 or
main
branch? https://godbolt.org should be helpful.
I cannot reproduce this with clang-19.
dtcxzyw@dtcxzyw:~/WorkSpace/Projects/compilers/LLVM/llvm-build$ clang -O2 -fsanitize=undefined -fsanitize=address --rtlib=compiler-rt -g -lgcc_s -O2 test.c
test.c:28:1: warning: return type of 'main' is not 'int' [-Wmain-return-type]
28 | void main()
| ^
test.c:28:1: note: change return type to 'int'
28 | void main()
| ^~~~
| int
1 warning generated.
dtcxzyw@dtcxzyw:~/WorkSpace/Projects/compilers/LLVM/llvm-build$ ./a.out
dtcxzyw@dtcxzyw:~/WorkSpace/Projects/compilers/LLVM/llvm-build$ echo $?
88
dtcxzyw@dtcxzyw:~/WorkSpace/Projects/compilers/LLVM/llvm-build$ clang -v
Ubuntu clang version 19.0.0 (++20240701042455+8598bcb9934d-1~exp1~20240701042602.1778)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-19/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /usr/local/cuda-11.7, version 11.7
dtcxzyw@dtcxzyw:~/WorkSpace/Projects/compilers/LLVM/llvm-build$
Could you please try 18 or
main
branch? https://godbolt.org should be helpful.
I tried clang-14 and trunk here https://godbolt.org/z/WKsav9387
Sorry, the runtime error message is in exec.err. Here is the updated console.
$ ../compiler-builds/llvmorg-14.0.6_build/bin/clang -fsanitize=undefined -fsanitize=address --rtlib=compiler-rt -g -lgcc_s -O2 testcase.c -o exec
$ timeout 1s ./exec 2>exec.err
$ cat exec.err
testcase.c:13:7: runtime error: subtraction of unsigned offset from 0x7ffe760240e0 overflowed to 0x7ffe760240f8 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior analysis/test960851-m.c:13:7 in AddressSanitizer:DEADLYSIGNAL ================================================================= ==351086==ERROR: AddressSanitizer: SEGV on unknown address 0x000041b58ab3 (pc 0x000041b58ab3 bp 0x7ffe76024190 sp 0x7ffe760240c8 T0) ==351086==The signal is caused by a READ memory access. AddressSanitizer:DEADLYSIGNAL AddressSanitizer: nested bug in the same thread, aborting.
$ ../compiler-builds/llvmorg-13.0.1_build/bin/clang -fsanitize=undefined -fsanitize=address --rtlib=compiler-rt -g -lgcc_s -O2 testcase.c -o exec
$ timeout 1s ./exec 2>exec.err
$ cat exec.err
Even 18 is near end of maintenance.
Hello, we are using clang to compile the above code in Ubuntu 22.04.3 LTS. We found a case that there are discrepancies when compiling with llvmorg-14.0.6 at -O2 and -O3. Is the discrepancy caused by infinite loop in the program? since the behavior is undefined before P2809.