Re: Further news on Clang - spurious warnings

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Further news on Clang - spurious warnings
Дата
Msg-id 1323.1312438080@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Further news on Clang - spurious warnings  (Peter Geoghegan <peter@2ndquadrant.com>)
Ответы Re: Further news on Clang - spurious warnings  (Peter Geoghegan <peter@2ndquadrant.com>)
Re: Further news on Clang - spurious warnings  (Greg Stark <stark@mit.edu>)
Список pgsql-hackers
Peter Geoghegan <peter@2ndquadrant.com> writes:
> On 3 August 2011 21:03, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I mean that it's unclear what you'll get if status has a bitpattern
>> equivalent to a negative integer. �If the compiler implements the
>> comparison as signed, the test will yield TRUE; if unsigned, it's FALSE.

> On compilers on which the enum value is represented as an unsigned
> int, passing -1 is just the same as doing that with any function with
> an unsigned int argument for that argument - it will convert to a
> large unsigned value . So sure, that isolated part of the test's
> outcome will vary depending on whether or not the compiler opts to
> represent the enum as signed when it can, but I don't look at it as
> you do. I simply consider that to be a violation of the enum's
> contract, or the caller's failure to consider that the enum couldn't
> represent -1 -- they got what they asked for.

This argument is completely missing the point of the test, which is to
verify whether or not the caller adhered to the enum's contract.  You
can *not* assume that he did while arguing about whether the test is
valid or accomplishes its goals.
        regards, tom lane


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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: Further news on Clang - spurious warnings
Следующее
От: Simon Riggs
Дата:
Сообщение: Re: Transient plans versus the SPI API