On 11/07/2010 06:57 AM,
wrote:
....
> I am changing the followup line to remove comp.lang.fortran,
> which is the only one of the groups I am following, but am going to
> respond.
>
> What you have posted was, indeed, the intent of the committee. It
> is not, however, what the C99 standard says. Like so much else of
> C99 (and a lot of C90), none of those facilities are usable in even
> remotely portable code because only their syntax and intent is
> defined by the standard - their semantics are, at most, implementation-
> defined and more often unspecified or even undefined. And, yes, I
> DO mean that using them is arguably undefined behaviour.
>
> FLT_EVAL_METHOD is unclear which operations it controls,
5.2.4.2.2p8 seems pretty clear: "operations with floating operands and
values". Can you come up with any argument, from the text of the
standard, why it should not apply to every "operation with floating
operands and values", or why it should apply to any operations that
don't fit that description? It doesn't have to be a great argument; just
good enough to justify your asserting that there's a lack of clarity.
Alternatively, identify a case where it's unclear whether or not that
description applies. I'm not saying that there are no such cases; only
that I can't think of any, and it would clarify the nature of your
complaint if I had an example to think about.
> ... and exactly
> when it applies (given that constant and dynamic evaluation are not
> required to be identical). ...
Nonetheless, 5.2.4.2.2p8 makes it quite clear that values 0, 1 and 2 all
identify behavior which covers constants as well as operations.
> ... It is also permitted to be set to -1,
So? Are you worse off having a way of knowing that the float evaluation
method is indeterminable than you would be if you didn't have any way to
determine that fact?
> and there are no specified constraints involving __STDC_IEC_559__
> or FP_CONTRACT or CX_LIMITED_RANGE.
> The float_t and double_t types are likely to be macros, because
> 7.12#2 states that they ARE built-in types for some values of
> FLT_EVAL_METHOD. That is incompatible with using typedefs for them
> in those cases. Also, unless FLT_EVAL_METHOD is 0, 1 or 2, they
> have no connexion with expression evaluation.
So? If FLT_EVAL_METHOD is 0, 1, or 2, there is a connection, which seems
somewhat useful to me. Having that connection, and being able to
determine what that connection is and whether it even exists, all seem
fairly useful. I don't see how having those features makes things worse
than when they didn't exist. At worst, FLT_EVAL_METHOD == 1, and you
have a way of finding out that out; which is slightly better than
knowing nothing at all about such issues.
> God alone knows what FP_CONTRACT means (let alone CX_LIMITED_RANGE)
> because there is no specification of how expressions are evaluated
> other than the "as if" rule, though many people will read Annex F
> to imply that there is. But, in any case, that applies only if
> both __STDC_IEC_559__ is 1 and pragma FENV_ACCESS is on.
So, it does have a meaning when __STDC_IEC_559__ is 1 and FENV_ACCESS is
on? How does the existence of the FP_CONTRACT, __STDC_IEC_559__ and
FENV_ACCESS features make the situation worse than when you had no way
of ever determining, from within your code, whether or not that meaning
applied?
> As someone who has a lot of experience with numerical portability and
> reliability, stretching over four decades and dozens of very different
> systems, my advice to anyone concerned with those is not to touch
> the new features of C99 with a bargepole. Write clean, portable
> code and don't rely on compiler-, hardware- and system-dependent
> facilities.
C99 provides ways of determining whether certain compiler-, hardware-,
and system-dependent facilities are supported. Why shouldn't code use
those facilities when they are supported, and choose an appropriate
fall-back method when they aren't (which might be to refuse to attempt
the calculation)? Granted, in many cases, it may be appropriate to
simply always use the fall-back, so there's no need to even check.
However, that's not always the case, and the new facilities allow you to
do something other than the fall back, if you want to. How does the
presence of those facilities make the situation any worse then it was
without them?