The results of the discussion can be summarized as follows:
1) There is the only (almost?) portable way to test the
value of address constants - to use additional variable:
extern _DYNAMIC[];
/* global - to avoid optimizations, though gcc I use doesn't
* optimize "if" when pDYNAMIC is local
*/
int * pDYNAMIC = _DYNAMIC;
...
{
if (pDYNAMIC) ....
else ....
}
I must note the error in some answers. Their authors
propose to test *_DYNAMIC. Obviously, this may cause NULL
pointer access and therefore coredump.
2) The source of strange behavior of the C compiler is
its origin. GCC tries to optimize the "if" always,
MS-DOS' Microsoft and Borland C don't make any presumptions about
the value of address constants, and only PCC-derived
compilers (3 of them have been tested, including SunOS')
behave strangely.
Thanks,
-- Leonid A. Broukhis
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:49 CDT