This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Your June 7 change to expand_expr
- To: kenner at vlsi1 dot ultra dot nyu dot edu
- Subject: Re: Your June 7 change to expand_expr
- From: Mark Mitchell <mark at markmitchell dot com>
- Date: Thu, 2 Jul 1998 18:59:19 -0700
- CC: egcs-bugs at cygnus dot com, jfc at mit dot edu, law at cygnus dot com, wilson at cygnus dot com
- References: <9807022250.AA21235@vlsi1.ultra.nyu.edu>
- Reply-to: mark at markmitchell dot com
Yes. But, no conforming program can ever have a NULL reference.
BTW, the Ada RM distinguishes between "illegal" and "erroneous". The
former is a static violation of the language rules which compilers are
required to diagnose at compile time and "erroneous" refers to a
program which violates a run-time restriction and for which the
compiler may generate code to do anything at all. I take it that
"conforming" means that it's neither illegal or erroneous in the Ada
sense.
Well, C and C++ have no notion of "compile-time" per se. But, some
violations "require a diagnostic"; a reference being NULL is not one
of them. Other result in "undefined behavior", which means, as you
say, that anything can happen. That's what (somehow) creating a NULL
reference would be: undefined behavior.
So, you're correct.
My point was that GCC could conceivably optimize certain operations by
knowing that things of REFERENCE_TYPE are non-NULL; doing so would
break no legal programs.
Can't it actually do more? Can't it assume that the address is a valid
address in memory? This can be quite important in things like Merced.
Yes, indeed; but this is true for just plain pointers too. (Well,
modulo the one-past-the-end-of-the-array thing, but even then you're
not allowed to *dereference* such a pointer. You're just allowed to
create it.) I don't believe you're allowed to create such a
reference.
--
Mark Mitchell mark@markmitchell.com
Mark Mitchell Consulting http://www.markmitchell.com