Issue 137518
Summary [clang] Regression: crash compiling dynamic_cast with final class and optimisation level higher than 0
Labels clang
Assignees
Reporter andyg1001
    Since clang 19, the following minimal code will crash the compiler when compiled with an optimisation level -O1 or higher:

```
class base { virtual void fn() = 0; };
class test final : base { virtual void fn() { } };
test* new_test() { return new test(); }

test* cast(base* b) {
  return dynamic_cast<test*>(b); // crash here!
}
```

On my PC, I get the error "fatal error: error in backend: Broken module found, compilation aborted!"

See demo here: https://godbolt.org/z/75odnc3Wo

Remove the 'final' on class test and the code will compile again.

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to