[clang++] extremely slow when trying to use undeclared identifiers · Issue #93308 · llvm/llvm-project (original) (raw)

Given a program in the following format:

void test() { int a11; [...] // a bunch more variable declarations not used afterwards

if( a97 == a95 ) {} // comparing non-existant variables }

clang++ can take up to 5 minutes compiling this or even crashes, while clang can compile it just fine.

Full code example

void test() { int a11; int a12; int a13; int a14; int* a15; int a16; int a17; int a18; int a22; int a24; int a25; int a35; int a36; int a37; int a38; int a39; int a40; int a42; int a91; int a92; int a98; int a99;

if( a97 == a95, a96 == a96, a97 == a96, a95 == a93, a96 == a105 ) {} }

The example above compiles for more than 5 minutes for me. Variants can be created by adding/removing more variable declarations, but the code is somehow very sensitive to working correctly (compiling in less than 0.1 second) again.

I'm not able to pinpoint what actually causes this to create an even more minimized example, but as it seems to be influenced by the variable names, I believe that the generator for "did you mean variable x instead?" is somehow at fault here.

Here's some other things I tried/observed:

After trying around with this for more than 3 hours without being able to further "destill" down the issue, let's hope someone else around here has a theory on why this occurs.

For experiments, feel free to test with this Godbolt:
Godbolt