Re: Nulls get converted to 0 problem

From: Samuel Tardieu <sam(at)rfc1149(dot)net>
To: kdebisschop(at)alert(dot)infoplease(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Nulls get converted to 0 problem
Date: 2003-06-06 15:31:40
Message-ID: 2003-06-06-17-31-40+trackit+sam@rfc1149.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>>>> "kdebisschop" == kdebisschop <kdebisschop(at)alert(dot)infoplease(dot)com> writes:

kdebisschop> if (str == "")
kdebisschop> printf ("This comparison above can segfault on some
kdebisschop> systems\n");

No, it can't. You are comparing pointers (str and a pointer to a NULL
string). This is exactly the same as comparing integers. If any
compiler generates code which does a segmentation fault, it is far
from being (even remotely) a C compiler (and I'm not being pedantic
here).

If you meant strcmp(str, "") that's a completely different story.

Sam
--
Samuel Tardieu -- sam(at)rfc1149(dot)net -- http://www.rfc1149.net/sam

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bill.Allie 2003-06-06 15:36:59 Re: Approved
Previous Message Jon Earle 2003-06-06 15:21:58 Re: Nulls get converted to 0 problem