https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111095

--- Comment #4 from mengli ming <dale.mengli.ming at proton dot me> ---
(In reply to David Malcolm from comment #1)
> Thanks for filing this bug.
> 
> This looks similar to bug 111213.
> 
> Adding -fdump-ipa-analyzer=stderr shows that at -O1 and above, the entire
> body of the function is optimized away before the analyzer even sees it
> (presumably due to undefined behavior).
> 
> My hypothesis is that the optimizer sees the undefined behavior and
> optimizes the function away (but I haven't checked the details).
> 
> If that's the case, that's a strong argument that the analyzer should run
> earlier. I'll open a bug about that.

Hi David, Under the -O0 optimization level, I found another issue with this
case. 

After commenting out irrelevant code like `for (int i = 0; i < 1; i++) ;` or
`union a h;`, the analyzer reports an out-of-bound warning. Moreover, changing
`*g = 0;` to `*g = 1;` also triggers the out-of-bound warning. It's puzzling.

Reply via email to