This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [google] Check if the nonnull attribute is applied to 'this' (issue4446070)
- From: Jason Merrill <jason at redhat dot com>
- To: Basile Starynkevitch <basile at starynkevitch dot net>
- Cc: Mike Stump <mikestump at comcast dot net>, Diego Novillo <dnovillo at google dot com>, reply at codereview dot appspotmail dot com, lcwu at google dot com, gcc-patches at gcc dot gnu dot org
- Date: Mon, 02 May 2011 17:51:05 -0400
- Subject: Re: [google] Check if the nonnull attribute is applied to 'this' (issue4446070)
- References: <20110429150824.C78D4AE1DD@tobiano.tor.corp.google.com> <20110429204606.bee27400.basile@starynkevitch.net> <E0028B05-0F13-4B38-9399-8B4A34FC1A63@comcast.net> <20110429220818.f51acef0.basile@starynkevitch.net>
On 04/29/2011 04:08 PM, Basile Starynkevitch wrote:
[...]
which is also what I expect. I have no idea if it is conforming to
standards. But I notice that the test about this is remaining in the
code. So apparently GCC 4.6 does not make the hypothesis that this is
never null, otherwise it would have optimized the test by removing it.
What I don't know (and I am asking) is if such an hypothetical
optimization is conforming to standards. My biased feeling is that it
is not (because I found no explicit& unambiguous mention in standard
legal text that this is never null).
9.3.1 seems pretty clear:
If a non-static member function of a class X is called for an object that is not of type X, or of a type derived
from X, the behavior is undefined.
A null pointer does not point to an object of type X, so the
optimization would be conforming.
Jason