pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #13788: compile error in generic_msvc.h
7+ messages / 4 participants
[nested] [flat]

* BUG #13788: compile error in generic_msvc.h
@ 2015-12-01 16:54 paul.moore@centrify.com
  2015-12-01 21:35 ` Re: BUG #13788: compile error in generic_msvc.h Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 7+ messages in thread

From: paul.moore@centrify.com @ 2015-12-01 16:54 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      13788
Logged by:          paul moore
Email address:      paul.moore@centrify.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




-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: BUG #13788: compile error in generic_msvc.h
  2015-12-01 16:54 BUG #13788: compile error in generic_msvc.h paul.moore@centrify.com
@ 2015-12-01 21:35 ` Tom Lane <tgl@sss.pgh.pa.us>
  2015-12-02 16:13   ` Re: BUG #13788: compile error in generic_msvc.h Paul Moore <paul.moore@centrify.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Tom Lane @ 2015-12-01 21:35 UTC (permalink / raw)
  To: paul.moore@centrify.com; +Cc: pgsql-bugs@postgresql.org, Andres Freund <andres@anarazel.de>

paul.moore@centrify.com writes:
> Bug reference:      13788
> Logged by:          paul moore
> Email address:      paul.moore@centrify.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


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: BUG #13788: compile error in generic_msvc.h
  2015-12-01 16:54 BUG #13788: compile error in generic_msvc.h paul.moore@centrify.com
  2015-12-01 21:35 ` Re: BUG #13788: compile error in generic_msvc.h Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-12-02 16:13   ` Paul Moore <paul.moore@centrify.com>
  2015-12-02 16:50     ` Re: BUG #13788: compile error in generic_msvc.h Andres Freund <andres@anarazel.de>
  0 siblings, 1 reply; 7+ messages in thread

From: Paul Moore @ 2015-12-02 16:13 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs; Andres Freund <andres@anarazel.de>

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@sss.pgh.pa.us] 
Sent: Tuesday, December 1, 2015 1:35 PM
To: Paul Moore <paul.moore@centrify.com>
Cc: pgsql-bugs@postgresql.org; Andres Freund <andres@anarazel.de>
Subject: Re: [BUGS] BUG #13788: compile error in generic_msvc.h

paul.moore@centrify.com writes:
> Bug reference:      13788
> Logged by:          paul moore
> Email address:      paul.moore@centrify.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


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: BUG #13788: compile error in generic_msvc.h
  2015-12-01 16:54 BUG #13788: compile error in generic_msvc.h paul.moore@centrify.com
  2015-12-01 21:35 ` Re: BUG #13788: compile error in generic_msvc.h Tom Lane <tgl@sss.pgh.pa.us>
  2015-12-02 16:13   ` Re: BUG #13788: compile error in generic_msvc.h Paul Moore <paul.moore@centrify.com>
@ 2015-12-02 16:50     ` Andres Freund <andres@anarazel.de>
  2015-12-03 17:02       ` Re: BUG #13788: compile error in generic_msvc.h Paul Moore <paul.moore@centrify.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Andres Freund @ 2015-12-02 16:50 UTC (permalink / raw)
  To: Paul Moore <paul.moore@centrify.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs

On 2015-12-02 16:13:07 +0000, Paul Moore wrote:
> 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

Given that win64 buildfarm members have happily been compiling this code
I suspect that's the cause. Are you including the headers with extern
"C" or not?

You're using SPI directly from C++? You got to be *very* careful doing
that - postgres uses longjmp which isn't necessarily compatible with C++
(doesn't call destructors to be called and such).


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: BUG #13788: compile error in generic_msvc.h
  2015-12-01 16:54 BUG #13788: compile error in generic_msvc.h paul.moore@centrify.com
  2015-12-01 21:35 ` Re: BUG #13788: compile error in generic_msvc.h Tom Lane <tgl@sss.pgh.pa.us>
  2015-12-02 16:13   ` Re: BUG #13788: compile error in generic_msvc.h Paul Moore <paul.moore@centrify.com>
  2015-12-02 16:50     ` Re: BUG #13788: compile error in generic_msvc.h Andres Freund <andres@anarazel.de>
@ 2015-12-03 17:02       ` Paul Moore <paul.moore@centrify.com>
  2015-12-10 15:14         ` Re: BUG #13788: compile error in generic_msvc.h Andres Freund <andres@anarazel.de>
  0 siblings, 1 reply; 7+ messages in thread

From: Paul Moore @ 2015-12-03 17:02 UTC (permalink / raw)
  To: Andres Freund <andres@anarazel.de>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs

Yes on extern "C". I have other stuff working

Really what I am trying to do is invoke c# code. I am going to need to call SPI. I tried to find out if anybody else had done it and found nothing.

The c++ code is simply a thin shim from native c to c#

-----Original Message-----
From: Andres Freund [mailto:andres@anarazel.de] 
Sent: Wednesday, December 2, 2015 8:50 AM
To: Paul Moore <paul.moore@centrify.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs@postgresql.org
Subject: Re: [BUGS] BUG #13788: compile error in generic_msvc.h

On 2015-12-02 16:13:07 +0000, Paul Moore wrote:
> 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

Given that win64 buildfarm members have happily been compiling this code I suspect that's the cause. Are you including the headers with extern "C" or not?

You're using SPI directly from C++? You got to be *very* careful doing that - postgres uses longjmp which isn't necessarily compatible with C++ (doesn't call destructors to be called and such).


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: BUG #13788: compile error in generic_msvc.h
  2015-12-01 16:54 BUG #13788: compile error in generic_msvc.h paul.moore@centrify.com
  2015-12-01 21:35 ` Re: BUG #13788: compile error in generic_msvc.h Tom Lane <tgl@sss.pgh.pa.us>
  2015-12-02 16:13   ` Re: BUG #13788: compile error in generic_msvc.h Paul Moore <paul.moore@centrify.com>
  2015-12-02 16:50     ` Re: BUG #13788: compile error in generic_msvc.h Andres Freund <andres@anarazel.de>
  2015-12-03 17:02       ` Re: BUG #13788: compile error in generic_msvc.h Paul Moore <paul.moore@centrify.com>
@ 2015-12-10 15:14         ` Andres Freund <andres@anarazel.de>
  2015-12-10 17:27           ` Re: BUG #13788: compile error in generic_msvc.h Paul Moore <paul.moore@centrify.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Andres Freund @ 2015-12-10 15:14 UTC (permalink / raw)
  To: Paul Moore <paul.moore@centrify.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs

Hi Paul,

As I don't have access to msvc: Could you try what Tom suggested in
http://archives.postgresql.org/message-id/5176.1449005701%40sss.pgh.pa.us ?

Regards,

Andres

On 2015-12-03 17:02:31 +0000, Paul Moore wrote:
> Yes on extern "C". I have other stuff working
> 
> Really what I am trying to do is invoke c# code. I am going to need to call SPI. I tried to find out if anybody else had done it and found nothing.
> 
> The c++ code is simply a thin shim from native c to c#
> 
> -----Original Message-----
> From: Andres Freund [mailto:andres@anarazel.de] 
> Sent: Wednesday, December 2, 2015 8:50 AM
> To: Paul Moore <paul.moore@centrify.com>
> Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs@postgresql.org
> Subject: Re: [BUGS] BUG #13788: compile error in generic_msvc.h
> 
> On 2015-12-02 16:13:07 +0000, Paul Moore wrote:
> > 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
> 
> Given that win64 buildfarm members have happily been compiling this code I suspect that's the cause. Are you including the headers with extern "C" or not?
> 
> You're using SPI directly from C++? You got to be *very* careful doing that - postgres uses longjmp which isn't necessarily compatible with C++ (doesn't call destructors to be called and such).
> 
> 
> -- 
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
Greetings,

Andres Freund


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: BUG #13788: compile error in generic_msvc.h
  2015-12-01 16:54 BUG #13788: compile error in generic_msvc.h paul.moore@centrify.com
  2015-12-01 21:35 ` Re: BUG #13788: compile error in generic_msvc.h Tom Lane <tgl@sss.pgh.pa.us>
  2015-12-02 16:13   ` Re: BUG #13788: compile error in generic_msvc.h Paul Moore <paul.moore@centrify.com>
  2015-12-02 16:50     ` Re: BUG #13788: compile error in generic_msvc.h Andres Freund <andres@anarazel.de>
  2015-12-03 17:02       ` Re: BUG #13788: compile error in generic_msvc.h Paul Moore <paul.moore@centrify.com>
  2015-12-10 15:14         ` Re: BUG #13788: compile error in generic_msvc.h Andres Freund <andres@anarazel.de>
@ 2015-12-10 17:27           ` Paul Moore <paul.moore@centrify.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Paul Moore @ 2015-12-10 17:27 UTC (permalink / raw)
  To: Andres Freund <andres@anarazel.de>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs

I put the cast in and it compiles with no complaint

-----Original Message-----
From: Andres Freund [mailto:andres@anarazel.de] 
Sent: Thursday, December 10, 2015 7:14 AM
To: Paul Moore <paul.moore@centrify.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs@postgresql.org
Subject: Re: [BUGS] BUG #13788: compile error in generic_msvc.h

Hi Paul,

As I don't have access to msvc: Could you try what Tom suggested in http://archives.postgresql.org/message-id/5176.1449005701%40sss.pgh.pa.us ?

Regards,

Andres

On 2015-12-03 17:02:31 +0000, Paul Moore wrote:
> Yes on extern "C". I have other stuff working
> 
> Really what I am trying to do is invoke c# code. I am going to need to call SPI. I tried to find out if anybody else had done it and found nothing.
> 
> The c++ code is simply a thin shim from native c to c#
> 
> -----Original Message-----
> From: Andres Freund [mailto:andres@anarazel.de]
> Sent: Wednesday, December 2, 2015 8:50 AM
> To: Paul Moore <paul.moore@centrify.com>
> Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs@postgresql.org
> Subject: Re: [BUGS] BUG #13788: compile error in generic_msvc.h
> 
> On 2015-12-02 16:13:07 +0000, Paul Moore wrote:
> > 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
> 
> Given that win64 buildfarm members have happily been compiling this code I suspect that's the cause. Are you including the headers with extern "C" or not?
> 
> You're using SPI directly from C++? You got to be *very* careful doing that - postgres uses longjmp which isn't necessarily compatible with C++ (doesn't call destructors to be called and such).
> 
> 
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make 
> changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
Greetings,

Andres Freund


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2015-12-10 17:27 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-12-01 16:54 BUG #13788: compile error in generic_msvc.h paul.moore@centrify.com
2015-12-01 21:35 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-12-02 16:13   ` Paul Moore <paul.moore@centrify.com>
2015-12-02 16:50     ` Andres Freund <andres@anarazel.de>
2015-12-03 17:02       ` Paul Moore <paul.moore@centrify.com>
2015-12-10 15:14         ` Andres Freund <andres@anarazel.de>
2015-12-10 17:27           ` Paul Moore <paul.moore@centrify.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox