<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/88100>88100</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Inconsistent Output on Different Optimization Levels for Uninitialized Structure Member Reference
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
iamanonymouscs
</td>
</tr>
</table>
<pre>
When compiling this code using Clang++ with the -O0 optimization level, the program executes successfully(see https://godbolt.org/z/6G4evhKE1). However, when using optimization levels -O1, -O2, or -O3, the program consistently returns an error code of 200(see https://godbolt.org/z/x9dzrd75j).
I am seeking clarification on whether this behavior can be considered a bug or a deliberate design choice.
# Version
```sh
clang version 19.0.0git (https://github.com/llvm/llvm-project.git 987087df90026605fc8d03ebda5a1cd31b71e609)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cTest/llvm-project/mybuild/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Selected multilib: .;@m64
```
# Command
`clang++ -fsanitize=undefined -O2 bug.c`
# Code
`cat bug.c`
```c
struct S {
int a;
};
int main() {
struct S s;
struct S *p = &s;
return p->a;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVNtu4zYTfhr6ZiCBomRZutBFYq_2X_wtAjTb9rKgyJHEXYo0eHAOT1_QcuKsCxQtUMAwxTl-881wuPdqMogd2d6T7WHDY5it6xRfuLHmZbHRC78ZrHzpCD0Qevf7jAaEXY5KKzNBmJUHYSVC9Om-19xMhN0Tdg9PKswQZoTsgYI9BrWoVx6UNaDxhJqw_Vl7dHZyfAF8RhEDevBRCPR-jFq_ENZ4RJhDOHpS3hHWE9ZPVg5Wh9y6ibD-lbC-_lzhaf7_p4KwNof_2Sc8oUsJnhLcFdpfEXjIHopkl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