From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Ryu floating point output patch |
Date: | 2019-02-17 21:34:58 |
Message-ID: | 5594.1550439298@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
BTW, another minor problem with this patch: various buildfarm members
are whining that
prairiedog | 2019-02-17 14:25:15 | ryu_common.h:111: warning: array subscript has type 'char'
This evidently is from the next-to-last line in
static inline int
copy_special_str(char *const result, const bool sign, const bool exponent, const bool mantissa)
{
if (mantissa)
{
memcpy(result, "NaN", 3);
return 3;
}
if (sign)
{
result[0] = '-';
}
if (exponent)
{
memcpy(result + sign, "Infinity", 8);
return sign + 8;
}
result[sign] = '0';
return sign + 1;
}
IMO, this is just awful coding, using a "bool" argument in
just one place as a boolean and in four other ones as an integer.
Aside from being cowboy coding, this has very serious risks of
misbehaving on platforms where "bool" isn't C99-like, so that
"sign" could potentially have values other than 0 and 1.
Please clean up that type-punning.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Justin Pryzby | 2019-02-17 21:48:00 | Re: Actual Cost |
Previous Message | Thomas Munro | 2019-02-17 21:26:12 | Re: REL_11_STABLE: dsm.c - cannot unpin a segment that is not pinned |