llvm / llvm/llvm-project

Clang-tidy bugprone-unchecked-optional-access doesn't work when #including <iox/optional.hpp>

Open
#168,310 4 comments 0 reactions 0 assignees View on GitHub
clang-tidy clang:dataflow false-negative
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

I just tried this code with clang-tidy built from main and noticed that `bugprone-unchecked-optional-access` doesn't work. If I comment out the `#include ` then it works as expected.

```
#include
#include
int foo(std::optional& val)
{
return *val;
}
```
Verified that this doesn't work with LLVM 21.1.5 as well (i.e. the check doesn't detect the unsafe dereference)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.