This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Your June 7 change to expand_expr



	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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]