Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Rocco Altier
> I suspect a patch to convert PostgreSQL to C++ wouldn't be > welcomed. Haha... > Checking my calendar, I think you are about 26 days too late to make that suggestion... -rocco ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread mark
On Thu, Apr 27, 2006 at 02:42:35PM -0500, Taral wrote: > On 27 Apr 2006 15:25:45 -0400, Greg Stark <[EMAIL PROTECTED]> wrote: > > It would be pretty cool to have a type-safe codebase. It just seems like > > too an awful lot of work for a mostly aesthetic improvement. > Does anyone have some benchm

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Tom Lane
Greg Stark <[EMAIL PROTECTED]> writes: > Tom Lane <[EMAIL PROTECTED]> writes: >> Doesn't achieve the same thing, unless you mandate that every part of >> the system use the identical massively-overloaded union struct to refer >> to every node. > Are you saying it's important to preserve the abil

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Taral
On 27 Apr 2006 15:25:45 -0400, Greg Stark <[EMAIL PROTECTED]> wrote: > It would be pretty cool to have a type-safe codebase. It just seems like too > an awful lot of work for a mostly aesthetic improvement. Does anyone have some benchmarks I can run? I can run tests to see if this aliasing makes a

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Greg Stark
Tom Lane <[EMAIL PROTECTED]> writes: > Greg Stark <[EMAIL PROTECTED]> writes: > > > There are other ways of achieving the same thing. Structs containing a union > > for the subclass fields for example. > > Doesn't achieve the same thing, unless you mandate that every part of > the system use the

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Martijn van Oosterhout
On Thu, Apr 27, 2006 at 12:21:55PM -0500, Taral wrote: > > If we do subclassing like this: > > > > struct Node { ... }; > > struct Value { struct Node; ... }; > > etc. > > > > do we still run into the alias problem? > > Nope, it appears to get rid of the alias problem completely. But it > requires

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Taral
On 4/27/06, Taral <[EMAIL PROTECTED]> wrote: > If we do subclassing like this: > > struct Node { ... }; > struct Value { struct Node; ... }; > etc. > > do we still run into the alias problem? Nope, it appears to get rid of the alias problem completely. But it requires anonymous structure support (

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Taral
On 4/27/06, Tom Lane <[EMAIL PROTECTED]> wrote: > Greg Stark <[EMAIL PROTECTED]> writes: > > There are other ways of achieving the same thing. Structs containing a union > > for the subclass fields for example. > > Doesn't achieve the same thing, unless you mandate that every part of > the system u

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Taral
On 4/27/06, Zeugswetter Andreas DCP SD <[EMAIL PROTECTED]> wrote: > Can you please explain what exactly was not working ? > xlc has in the past shown warnings that were actually problematic code > that gcc did not show (and the cc variant of xlc also does not show). This has nothing to do with war

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Tom Lane
Greg Stark <[EMAIL PROTECTED]> writes: > Martijn van Oosterhout writes: >> You're right, PostgreSQL uses a form of subclassing, so that a (for >> example) struct ArrayRefExprState is occasionally referred to using a >> (struct ExprState*) or even a (struct Node*). In C, the logical way to >> get t

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Greg Stark
Martijn van Oosterhout writes: > You're right, PostgreSQL uses a form of subclassing, so that a (for > example) struct ArrayRefExprState is occasionally referred to using a > (struct ExprState*) or even a (struct Node*). In C, the logical way to > get that to work it by casting, do you have a bet

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Martijn van Oosterhout
On Thu, Apr 27, 2006 at 11:08:59AM -0400, [EMAIL PROTECTED] wrote: > ... If > PostgreSQL isn't alias safe - it means that there is casting > happening, that is not generally accepted as valid, minimizing the > optimization potential of the code, and certainly not guaranteed to be > correct. Every c

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Zeugswetter Andreas DCP SD
> I ran afoul of these rules the other day when compiling pgsql 8.1 on > AIX. The configure scripts are set up to look for "xlc" instead of > "cc", and that command invokes cc with "-qalias=ansi", the ANSI-strict > pointer aliasing mode. Can you please explain what exactly was not working ? xlc h

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread mark
On Thu, Apr 27, 2006 at 10:49:02AM -0400, Tom Lane wrote: > [EMAIL PROTECTED] writes: > > Even if it was only 1% - 2%. Isn't it worth it? :-) > No. According to the ancient saying, "I can make this program > arbitrarily fast ... if it doesn't have to give the right answer". > Percentage-point impr

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Tom Lane
[EMAIL PROTECTED] writes: > Even if it was only 1% - 2%. Isn't it worth it? :-) No. According to the ancient saying, "I can make this program arbitrarily fast ... if it doesn't have to give the right answer". Percentage-point improvements are not worth the risk of introducing hard-to-find, compil

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread mark
On Thu, Apr 27, 2006 at 12:52:42PM +0200, Martijn van Oosterhout wrote: > > Next time we have this discussion I wish someone would actually document > > the performance differences. IIRC most of what I have seen makes it at > > best marginal. > I can imagine there are cases where the performance

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Tom Lane
Martijn van Oosterhout writes: > That's right, except I read "object", not "primative type". The > question revolves a bit around what an object is. This discussion on > the GCC lists [1] suggests that the syntax a->b is merely syntactic > sugar for (*a).b and thus the "object" being accessed is (

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Martijn van Oosterhout
On Thu, Apr 27, 2006 at 07:34:19PM +0930, Andrew Dunstan wrote: > Next time we have this discussion I wish someone would actually document > the performance differences. IIRC most of what I have seen makes it at > best marginal. I can imagine there are cases where the performance difference is n

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Andrew Dunstan
Taral wrote: 4. Find the option for disabling strict alias and get configure to add that. You'll still lose performance, but the option is "-qalias=noansi". Next time we have this discussion I wish someone would actually document the performance differences. IIRC most of what I ha

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Zeugswetter Andreas DCP SD
> > 4. Find the option for disabling strict alias and get configure to add > > that. > > You'll still lose performance, but the option is "-qalias=noansi". My old xlc does not show that option, it is unfortunately version specific. The currently compatible option to turn it off would be -qnoansi

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-27 Thread Martijn van Oosterhout
On Wed, Apr 26, 2006 at 08:13:21PM -0400, Tom Lane wrote: > Actually, if xlc is behaving as Taral says then I'm pretty convinced > it's *broken*; it is assuming far more than is allowed even by the ANSI > aliasing rules. As I read the spec, ANSI aliasing says that a given > value must always be ac

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-26 Thread mark
On Wed, Apr 26, 2006 at 11:42:11PM -0400, Greg Stark wrote: > Tom Lane <[EMAIL PROTECTED]> writes: > > As I read the spec, ANSI aliasing says that a given value must always be > > accessed through equivalent (up to signedness) primitive types > It there a difference between C89 and C99 here? I bel

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-26 Thread Greg Stark
Tom Lane <[EMAIL PROTECTED]> writes: > As I read the spec, ANSI aliasing says that a given value must always be > accessed through equivalent (up to signedness) primitive types It there a difference between C89 and C99 here? -- greg ---(end of broadcast)--

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-26 Thread Tom Lane
Martijn van Oosterhout writes: > In the grandparent's case I think > the compiler is being really stupid because it can know the two > pointers are the same. But I'm sure there are more subtle cases where > it won't know. PostgreSQL typecasts pointers fairly freely. Actually, if xlc is behaving a

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-26 Thread Taral
On 4/26/06, Martijn van Oosterhout wrote: > Well, there are a number of fixes, it's questionable whether it's worth > the effort. In GCC you can mark structures that are aliased to avoid > the problem (attribute((may_alias)) iirc), but we don't do that. There's also C99's "restrict". > 4. Find t

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-26 Thread Martijn van Oosterhout
On Wed, Apr 26, 2006 at 04:58:31PM -0400, Tom Lane wrote: > We've looked at this before. There's no way we are buying into the > strict aliasing rules: it's not so much the code we know will break, > as the fear of what we don't know about. gcc, at least, is utterly > useless about warning about

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-26 Thread Martijn van Oosterhout
On Wed, Apr 26, 2006 at 03:45:00PM -0500, Taral wrote: > I ran afoul of these rules the other day when compiling pgsql 8.1 on > AIX. The configure scripts are set up to look for "xlc" instead of > "cc", and that command invokes cc with "-qalias=ansi", the ANSI-strict > pointer aliasing mode. Postg

Re: [HACKERS] ANSI-strict pointer aliasing rules

2006-04-26 Thread Tom Lane
Taral <[EMAIL PROTECTED]> writes: > I ran afoul of these rules the other day when compiling pgsql 8.1 on > AIX. The configure scripts are set up to look for "xlc" instead of > "cc", and that command invokes cc with "-qalias=ansi", the ANSI-strict > pointer aliasing mode. We've looked at this befor

[HACKERS] ANSI-strict pointer aliasing rules

2006-04-26 Thread Taral
I ran afoul of these rules the other day when compiling pgsql 8.1 on AIX. The configure scripts are set up to look for "xlc" instead of "cc", and that command invokes cc with "-qalias=ansi", the ANSI-strict pointer aliasing mode. Specifically, in this mode, the compiler assumes that accesses via p