home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.sys.sun.misc:4013 comp.lang.c:13044
- Newsgroups: comp.sys.sun.misc,comp.lang.c
- Path: sparky!uunet!mcsun!fuug!kiae!relcom!news-server
- From: Leonid A. Broukhis <leo@ipmce.su>
- Subject: SUMMARY: Strange error in C compiler
- Message-ID: <6337.715296315@kiae.su>
- Keywords: dynamic linking C compilation constant pointer
- Lines: 34
- Sender: news-server@kiae.su
- Reply-To: leo@ipmce.su
- Organization: unknown
- References: <13271.714953297@kiae.su> <25820@dog.ee.lbl.gov>
- Date: Mon, 31 Aug 1992 20:41:13 +0400
-
- 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
-
-
-