This is the mail archive of the
mailing list for the GCC project.
Re: GNU Coding Standards -- updated
- To: Joe Buck <jbuck at synopsys dot COM>
- Subject: Re: GNU Coding Standards -- updated
- From: Fergus Henderson <fjh at cs dot mu dot oz dot au>
- Date: Thu, 16 Aug 2001 15:27:16 +1000
- Cc: carlo at alinoe dot com (Carlo Wood), pfeifer at dbai dot tuwien dot ac dot at (Gerald Pfeifer), gcc at gcc dot gnu dot org, mark at codesourcery dot com (Mark Mitchell)
- References: <20010815161239.A26894@alinoe.com> <200108160133.SAA11236@atrus.synopsys.com>
On 15-Aug-2001, Joe Buck <jbuck@synopsys.COM> wrote:
> On Solaris, for gcc 2.95.2, code from both branches appears, but the
> branch is unconditional (no if-test). That is, the call to a appears
> in the assembly language code but it is unreachable.
> For gcc 3.0, only the call to b is generated; there is no branch.
When using this technique, some care will be required when writing code with
gcc 3.0 to make sure that it remains portable to gcc 2.95.2 and other C
compilers. In particular, it's important to ensure that all symbols referenced
in the branches which get optimized out are defined. So for example
you should continue to use conditional compilation for cases where you call
a function that will be defined on one system but not on other systems.
For example, here's one from read_include_file() in cppfiles.c:
if (pagesize == -1)
pagesize = getpagesize ();
if (size / pagesize >= MMAP_THRESHOLD)
buf = (U_CHAR *) mmap (0, size, PROT_READ, MAP_PRIVATE, inc->fd, 0);
if (buf == (U_CHAR *)-1)
inc->mapped = 1;
That needs to stay as an `#if' rather than an `if' because some systems don't
Fergus Henderson <email@example.com> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.