This is the mail archive of the gcc@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]
Other format: [Raw text]

Re: Null pointer check elimination


Diego Novillo wrote:
On Saturday 12 November 2005 12:05, Per Bothner wrote:

A "function-never-returns-null" attribute doesn't seem like
the right mechanism.  Instead, there should be a "never-null"
attribute on pointer types.  A "function-never-returns-null" is
just a function whose return-type has the "never-null" attribute.


I disagree. We would have to prove that every possible instance of this type is non-NULL.

I think you're missing the point. The proposal is for a "type variant" - not that different from say "constant".

"non-null java.lang.String" is a different POINTER_TYPE object than
"[possibly-null] java.lang.String".  If you dereference an expression
whose type is "non-null java.lang.String" then you know you don't need
an null pointer check.  If you derefernce an expression of type
"[possibly-null] java.lang.String" then you do need the null pointer
check.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


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