Re: Ryu floating point output patch

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Ryu floating point output patch
Дата
Msg-id 5594.1550439298@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Ryu floating point output patch  (Andrew Dunstan <andrew.dunstan@2ndquadrant.com>)
Ответы Re: Ryu floating point output patch  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Список 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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Thomas Munro
Дата:
Сообщение: Re: REL_11_STABLE: dsm.c - cannot unpin a segment that is not pinned
Следующее
От: Justin Pryzby
Дата:
Сообщение: Re: Actual Cost