[cfe-dev] Unspecified Condition
Keane, Erich via cfe-dev
cfe-dev at lists.llvm.org
Mon Jun 15 06:36:03 PDT 2020
In the context of the question (or at least, the OP's original intent for the question😊 ):
A compiler crashing is not a valid unspecified behavior. We should be properly handling it, but it DOES mean that the result we give isn't guaranteed by the standard. We don't have a way in the compiler of saying "the result of this expression is unspecified", it just means we have a little more freedom with what the behavior IS!
So yes, we do need to handle this in the compiler, we shouldn't allow it to continue crashing, and we can choose among a number of behaviors permitted by the standard.
-----Original Message-----
From: cfe-dev <cfe-dev-bounces at lists.llvm.org> On Behalf Of David Blaikie via cfe-dev
Sent: Sunday, June 14, 2020 2:12 PM
To: Gousemoodhin Nadaf <nadafgouse5 at gmail.com>
Cc: Clang Dev <cfe-dev at lists.llvm.org>
Subject: Re: [cfe-dev] Unspecified Condition
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
_______________________________________________
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