<div dir="ltr">Hi Devs,<br>going by this link <a href="https://llvm.org/docs/LangRef.html#floatenv">https://llvm.org/docs/LangRef.html#floatenv</a><br>it says that floating point operation does not have side effects by defaults.<br>but when compile a test case<br>i.e.<br>cat a.c<br>float foo(float a, float b)<br>{<br>return a+b;<br>}<br><br>$clang a.c -O2 -S -emit-llvm<br>emit ir like:<div>$cat a.ll<br><div>---------------------------------------  <br>; ModuleID = 'a.c'<br>source_filename = "a.c"<br>target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"<br>target triple = "x86_64-unknown-linux-gnu"<br><br>; Function Attrs: norecurse nounwind readnone uwtable<br>define dso_local float @foo(float %a, float %b) local_unnamed_addr #0 {<br>entry:<br>  %add = fadd float %a, %b<br>  ret float %add<br>}<br><br>attributes #0 = { norecurse nounwind readnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" <font color="#ff0000">"no-trapping-math"="false"</font> "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }<br>---------------------<br>and the setting "no-trapping-math"="false" should mean -ftrapping-math but it does not and it also contradict with documentation.<br></div></div><div><br></div><div>I think clang should emit this "no-trapping-math"="true" by default if it goes with this assumption  <a href="https://llvm.org/docs/LangRef.html#floatenv">https://llvm.org/docs/LangRef.html#floatenv</a> ?</div><div>what is default behavior of clang -fno-trapping-math or -ftrapping-math?</div><div>also clang default behavior does not match gcc?</div><div><a href="https://godbolt.org/z/B3YvxE">https://godbolt.org/z/B3YvxE</a><br></div><div><br></div><div>./kamlesh</div><div><br></div><div><br></div></div>