← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Remove check for undefined behaviour

 

On Wed, Sep 28, 2016 at 11:24 PM, Wayne Stambaugh <stambaughw@xxxxxxxxx> wrote:
> I normally don't like to rant but OMFG!  I just looked at the code path
> that lead to this wonderful piece of code and I'm now regretting that.
> You just cannot unsee that.  See if you can follow the logic (assuming
> logic was actually used to write this code) backwards from
> Triangle::NeighborAcross().  I'm not sure removing the invalid null
> reference checks is a good idea even though I've seen the compiler
> complain about it and agree with it.  In what universe do you blindly
> convert a potentially NULL pointer into a C++ reference, pass it to the
> caller, and go merrily on you way?  This really needs to be rewritten
> using pointers with the appropriate NULL pointer checks along the way.
> It's hard to imagine this ever worked properly.
>

This was actually a problem with earlier versions of OpenCascade. Some
devs were being too clever I guess and when clang and gcc changed
their behavior OpenCascade would segfault. But why anyone would
ever open up a situation where a NULL pointer is actually cast to a
reference still eludes me.

- Cirilo

> On 9/27/2016 1:33 PM, Simon Richter wrote:
>>
>> Triangle::NeighborAcross returns a reference, which must refer to a valid
>> object whose address cannot be 0. Thus, this test is nonsensical.
>> ---
>>  polygon/poly2tri/sweep/sweep.cc | 16 ----------------
>>  1 file changed, 16 deletions(-)
>>
>>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers
>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~kicad-developers
>> More help   : https://help.launchpad.net/ListHelp
>>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp


References