integer overflow in reloption.h

Started by Zdenek Kotalaover 16 years ago2 messages
#1Zdenek Kotala
Zdenek.Kotala@Sun.COM

When I compile postgresql now I get following message:

"../../../src/include/access/reloptions.h", line 45: warning: integer
overflow detected: op "<<"

The problem is on the following lines

typedef enum relopt_kind
{
...
RELOPT_KIND_MAX = (1 << 31)
}

enum is int datatype and 1 << 31 == -2147483648. It is reason why
compiler (sun studio) complains.

Is possible to change it to 1 << 30 to stop compiler generates noise?

Thanks Zdenek

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Zdenek Kotala (#1)
Re: integer overflow in reloption.h

Zdenek Kotala <Zdenek.Kotala@Sun.COM> writes:

The problem is on the following lines

typedef enum relopt_kind
{
...
RELOPT_KIND_MAX = (1 << 31)
}

enum is int datatype and 1 << 31 == -2147483648. It is reason why
compiler (sun studio) complains.

Is possible to change it to 1 << 30 to stop compiler generates noise?

Yeah, but we also have to fix the code that uses it. Done.

regards, tom lane