|From:||Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>|
|To:||Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>|
|Cc:||pgsql-hackers(at)postgresql(dot)org, Andres Freund <andres(at)anarazel(dot)de>|
|Subject:||Re: Ryu floating point output patch|
|Views:||Raw Message | Whole Thread | Download mbox | Resend email|
>>>>> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
Tom> result[sign] = '0';
Tom> IMO, this is just awful coding, using a "bool" argument in just
Tom> one place as a boolean and in four other ones as an integer. Aside
Tom> from being cowboy coding, this has very serious risks of
Tom> misbehaving on platforms where "bool" isn't C99-like, so that
Tom> "sign" could potentially have values other than 0 and 1.
Elsewhere in the code it relies fairly heavily on the result of boolean
expressions being exactly 0 or 1 (which I'm pretty sure is required in
C89, not just C99); the only two places in the upstream that actually
required C99-specific boolean semantics were fixed in da6520be7.
Obviously I'll fix the warning, but how strict do you want to be about
the rest of the code? There are a lot of examples of things like,
const uint32 q = log10Pow5(-e2) - (-e2 > 1);
output = vr + (vr == vm || roundUp);
The code as it stands now follows the rule that nothing is ever assigned
to a "bool" variable, parameter, or result except the result of a
logical expression; and given that, that the value of any "bool"
variable interpreted as an integer is 0 or 1 and no other value.
|Next Message||Tom Lane||2019-02-17 22:31:43||Re: BUG #15572: Misleading message reported by "Drop function operation" on DB with functions having same name|
|Previous Message||Justin Pryzby||2019-02-17 22:21:29||Re: dsa_allocate() faliure|