Clang-19.0 : Hang Issue with LLVM: No Output or Error Message involving recursive macros within a function
Description
I encountered an issue where the compiler hangs indefinitely while trying to compile a specific piece of code involving recursive macros within a function(https://godbolt.org/z/q6Gaz3c8r). The code snippet is provided below.GCC also has this problem(https://godbolt.org/z/9Exof1rrW).
Command
clang code_0.c -O3 -Wall -Wextra -fverbose-asm -fopt-info-vec-optimized -c -o code_0
Code
int a(int c) {
if (c < 12345) {
#define A \
{ int d = c % 12345; \
int e = c ^ d * 12345; \
int f = c * d % e % 12345; \
c = f; }
#define B A A A A A A
#define C B B B B B B
#define D C C C C C C
#define E D D D D D D
E E E E E
}
return c;
}
Version
# clang -v
Ubuntu clang version 19.0.0 (++20240301064251+dd426fa5f931-1~exp1~20240301184412.1845)
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/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Candidate multilib: .;@m64
Selected multilib: .;@m64
Output
Nothing (Waited for nearly 300 seconds.
Waited for nearly 300 seconds.
Halting problem solved!
I can abolutely imagine it taking longer than that. But apart from that, can you just use clang -E to get the preprocessed sources without any compilation and check how long that takes?
But apart from that, can you just use
clang -Eto get the preprocessed sources without any compilation and check how long that takes?
Very fast, almost finished as soon as I started compiling. Here is the result: test.tar.gz