vision-dbms / vision

The master repository for the Vision database system.
https://vision-dbms.com
BSD 3-Clause "New" or "Revised" License
27 stars 12 forks source link

Recent compilers are no longer willing to generate code that tests if 'this' is null #35

Closed MichaelJCaruso closed 6 years ago

MichaelJCaruso commented 6 years ago

The most recent versions of a number of standard C++ compilers are no longer willing to generate code that compares a method's this pointer to null. While trivially easy to invoke non-virtual class members using a null pointer, the standard considers this to be undefined behavior. While compilers and libraries (the Microsoft C++ libraries, for example) have long supported and used this (anti-?)pattern, that's changing. GCC 6.3 (the standard compiler in the Ubuntu 17.x distributions, for example) silently refuses to generate code for the test, optimizing away code paths it now considers to be unreachable because this can never be null. g++ is apparently not alone in that regard - there are reports that modern versions of clang do the same thing.

Unfortunately, some of the oldest C++ code in Vision null tests this, sometimes as a crash guard and sometimes to simplify program logic. The result, unsurprisingly, is code that crashes when it used to work.

MichaelJCaruso commented 6 years ago

Resolved by multiple commits.