News for hackers. Stuff that matters.
Re:Recommendations about coding in C++ by nwatson on Sunday February 19, 2017 @03:56PM (#13681924)
This used to compile and work just fine years ago (perhaps relying on undefined behavior):

    static void takes_null_reference_by_default(int& p = *((int*) nullptr)) {
        if (&p) ++p;
    }

    int main(int argc, char* argv[]) {
        int v1 = 15;
        int v2 = 25;
        takes_null_reference_by_default(v1);
        takes_null_reference_by_default();
        takes_null_reference_by_default(*((int*) nullptr));
        takes_null_reference_by_default(v2);
        std::cout << v1 << " " << v2 << std::endl;
    }
Now g++ complains with: junk.cpp:5:10: warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; pointer may be assumed to always convert to true [-Wundefined-bool-conversion]

./a.out still runs though. And the de-references are just pseudo-de-references, it never "really" happens.

EDIT: also mentioning the fits "delete this;" gave some people, but worked very well in the ACE Networking Library and various other places.

Re:Recommendations about coding in C++ by Animats on Sunday February 19, 2017 @05:29PM (#13682486)
"delete this" was obsolete around 20 years ago. It was considered valid C++ in the very early days, but that was a long time ago.
Re:Recommendations about coding in C++ by pjmlp on Sunday February 19, 2017 @07:10PM (#13683106)
Pretty much actual if you are on Windows, doing either MFC or COM.

And COM is future of Win32, rebranded as UWP.