Re: BUG #13788: compile error in generic_msvc.h

From: Paul Moore <paul(dot)moore(at)centrify(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: BUG #13788: compile error in generic_msvc.h
Date: 2015-12-02 16:13:07
Message-ID: BN4PR07MB2131DF8027DFBFD628475070F10E0@BN4PR07MB2131.namprd07.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The 32 bit functions are defined on unsigned types

From winbase.h

FORCEINLINE
unsigned
InterlockedCompareExchange(
_Inout_ _Interlocked_operand_ unsigned volatile *Destination,
_In_ unsigned Exchange,
_In_ unsigned Comperand
)
{
return (unsigned) _InterlockedCompareExchange((volatile long*) Destination, (long) Exchange, (long) Comperand);
}

The cast fixes the 64 bit case.

Full disclosure, I am compiling as c++. I think that might be the cause. I tried in a c project and did not get the same error

-----Original Message-----
From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Tuesday, December 1, 2015 1:35 PM
To: Paul Moore <paul(dot)moore(at)centrify(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org; Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: [BUGS] BUG #13788: compile error in generic_msvc.h

paul(dot)moore(at)centrify(dot)com writes:
> Bug reference: 13788
> Logged by: paul moore
> Email address: paul(dot)moore(at)centrify(dot)com
> PostgreSQL version: 9.5beta1
> Operating system: win server 2012
> Description:

> vs 2015, compiling spi execq sample

> vc complains about this

> 1>c:\Program
> Files\PostgreSQL\9.5\include\server\port/atomics/generic-msvc.h(91):
> error
> C2664: 'LONG64 _InterlockedCompareExchange64(volatile LONG64
> *,LONG64,LONG64)': cannot convert argument 1 from 'volatile uint64 *'
> to 'volatile LONG64 *'

> same for the add64 function a few lines later

That's a bit weird. A perhaps plausible explanation would be that the compiler is unhappy about passing an unsigned argument to a signed parameter; but if they've tightened it up like that, why no similar complaint for the 32-bit versions just above these?

Can you try inserting a cast to (volatile int64 *), just to see?

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2015-12-02 16:50:26 Re: BUG #13788: compile error in generic_msvc.h
Previous Message Alex Maslennikov 2015-12-02 15:50:50 Re: BUG #13789: pg_admin produces table definitiona instead of a view