`-fsanitize=undefined` does not detect uninitialized lvalue
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
ISO C23 6.3.2.1p2 says: "If the lvalue designates an object of automatic storage duration that could have been declared with the register storage class (never had its address taken), and that object is uninitialized (not declared with an initializer and no assignment to it has been performed prior to use), the behavior is undefined."
But on the following C code compiled with Clang 22.1.6 and `-fsanitize=undefined` under Debian/unstable, I do not get any warning.
```c
int main(void)
{
int x;
return x;
}
```
Note that this should not be confused with "MemorySanitizer: use-of-uninitialized-value" obtained by using `-fsanitize=memory`, because the following code also triggers a MemorySanitizer warning while this is not undefined behavior (the condition "never had its address taken" is not satisfied).
```c
int main(void)
{
int x;
(void) &x;
return x;
}
```
Said otherwise, one cannot distinguish these two cases while there is a difference for ISO C23.
Contributor guide
Assessment
This issue has not been assessed yet.