[cfe-dev] Unspecified Condition

David Blaikie via cfe-dev cfe-dev at lists.llvm.org
Sun Jun 14 14:12:21 PDT 2020


Your program's behavior probably shouldn't depend on any specific
unspecified behavior.
Sometimes it's not possible to avoid invoking unspecified behavior.
For instance - the evaluation order for function arguments is
unspecified, so in "f1(f2(), f3())" it's unspecified whether f2() or
f3() is run first - you can't really /avoid/ that unspecified behavior
if you're writing C++ (maybe you could write "auto &&x = f2(); auto
&&y = f3(); f1(std::move(x), std::move(y)); but implicit conversions,
by-value copies/moves, etc, would still trip this up) - the only thing
to do is ensure that your program does what you want/produces the same
result no matter whether f2 or f3 is run first.

On Sun, Jun 14, 2020 at 11:16 AM Gousemoodhin Nadaf via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> Hello Team,
> I just wanted to understand, If any condition is unspecified (for example comparison between fixed point and floating point), do we need to handle unspecified cases in code OR we should not keep such cases in our program?
>
> Regards,
> Nadaf.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


More information about the cfe-dev mailing list