snogglethorpe / snogray

Snogray renderer

Home Page:http://www.nongnu.org/snogray

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The Ref class can incorrectly create a null reference, which is UB

snogglethorpe opened this issue · comments

The Ref class contains this definition:

T &operator* () const { return *obj; }

... which is Undefined Behavior if obj is null.

gcc doesn't actually care (so far), and just does the straightforward thing with this, which is just to treat null references like null pointers... and unfortunately Ref depends on this. Recent versions of clang, on the other hand, use the UB as an excuse to remove some null checks, which causes the program to crash.

Fixed in b70caef