The Ref class can incorrectly create a null reference, which is UB
snogglethorpe opened this issue · comments
Miles Bader commented
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.
Miles Bader commented
Fixed in b70caef