Re: Further news on Clang - spurious warnings - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Further news on Clang - spurious warnings
Date
Msg-id 1323.1312438080@sss.pgh.pa.us
Whole thread Raw
In response to Re: Further news on Clang - spurious warnings  (Peter Geoghegan <peter@2ndquadrant.com>)
Responses Re: Further news on Clang - spurious warnings
Re: Further news on Clang - spurious warnings
List 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 by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Further news on Clang - spurious warnings
Next
From: Simon Riggs
Date:
Subject: Re: Transient plans versus the SPI API