[PATCH v2] Refactor to avoid nonnull checks on "this" pointer.

Corinna Vinschen corinna-cygwin@cygwin.com
Fri Apr 1 15:09:00 GMT 2016


On Apr  1 08:12, Yaakov Selkowitz wrote:
> On 2016-04-01 07:13, Corinna Vinschen wrote:
> >On Mar 31 12:18, Peter Foley wrote:
> >>G++ 6.0 asserts that the "this" pointer is non-null for member functions.
> >>Refactor methods that check if this is non-null to be static where
> >>necessary, and remove the check where it is unnecessary.
> >
> >No, sorry, but now.  Converting all affected functions to static
> >functions just because this might be null is much too intrusive for my
> >taste.  *If* that's really a problem going forward, I'd rather see the
> >pointer test moved into the caller.  But don't waste your time on a
> >patch yet.
> >
> >Let's please take a step back and look at what happens.  So, here's the
> >question:  What error message does G++ 6 generate in case of an `if
> >(this)' test in a member function, and why on earth should it care and
> >do that?
> 
> See https://gcc.gnu.org/gcc-6/porting_to.html, section named "Optimizations
> remove null pointer checks for this".

Oh well.  I kind of start to miss the K&R times...

Just kidding.  I think.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20160401/fac3b59c/attachment.sig>


More information about the Cygwin-patches mailing list