Mark, On Wed, Apr 09, 2008 at 10:05:35AM +0100, Mark Cave-Ayland wrote: > Taking a look at the committed fix, I see that you have the following: > > if ( sr_id && strcmp(sr_id,"-1") ) printf("SRID=%s;", sr_id); > > I have a very strong feeling that evaluation order in C is unspecified, > rather > than being from left to right; so for example the compiler could decide to > generate code that evaluates the strcmp() first, in which case it would > segfault on a NULL :( I think you would need to re-write something like this: > > if (sr_id) > if (strcmp(sr_id,"-1") ) printf("SRID=%s;", sr_id);
Your "very strong feeling" is wrong in this case. Evaluation order for function arguments in C is not specified. However, '&&' and '||' are not functions. In C/C++, and several other languages, '&&' and '||' are short-circuit operators, NOT logical operators. Millions of lines of C (or C++, Java, Perl, JavaScript, etc.) would crash or otherwise fail if constructs like if (ptr && *ptr) { /* do something */ } did not work as expected. See http://en.wikipedia.org/wiki/Short-circuit_evaluation for a more complete description of this common computer language feature. Cheers, Chris LaReau Technology Primate Korora, LLC _______________________________________________ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users