You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Working on example for #47526 I noticed that if loop body in panic_fmt is empty AND it is declared as extern "C" then optimizer will assume that the loop have no effects and will eliminate panic
As you can see, assert code is eliminated. However, if I add something that has side-effects (as in original example) or remove extern "C" call will be compiled as
Same root cause as #38136 (loop {} being UB, tracked in #28728). There's likely no deep reason why extern "C" makes a difference, LLVM's removal of empty loops is just very brittle (intentionally, I believe, to miscompile less real world C code).
Working on example for #47526 I noticed that if loop body in
panic_fmt
is empty AND it is declared asextern "C"
then optimizer will assume that the loop have no effects and will eliminate panicSo for this code
LLVM IR looks like
As you can see,
assert
code is eliminated. However, if I add something that has side-effects (as in original example) or removeextern "C"
call will be compiled asThe text was updated successfully, but these errors were encountered: