llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.58k stars 11.81k forks source link

clang-tidy SEGFAULT on bugprone-unchecked-optional-access #97426

Open andy31415 opened 3 months ago

andy31415 commented 3 months ago

I have somewhat template-heavy C++ source file that uses std::optional among other things. I seem to get a segfault on clang-tidy 18.1.3.

Stack trace attached.

tidy_segfault_trace.txt

andy31415 commented 3 months ago

Underlying reason may be that we have a wrapper class for std::optional (because historical reasons) so something named chip::Nullable is actually a std::optional with a set of renamed methods e.g. Value is std::optional::value. This seems to make clang-tidy unhappy.

andy31415 commented 3 months ago

2nd crash in the code from Tennessee is similar: using the chip class Nullable : protected std::optional<T> causes clang-tidy segfaults. That code path seems to be smaller than what I had, so there is a better chance to create some stand-alone reproduction case.