C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Calling methods on a nullptr

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Thu, 31 Oct 2024 19:26:13 +0000
On Thu, 31 Oct 2024 at 15:25, Tiago Freire <tmiguelf_at_[hidden]> wrote:

> The point of a method is to interact with an object.
> A nullptr cannot be an object.
> Can anyone cite a programing principle in which you would want to interact
> with an object that is not an object?
>

When exploiting memory safety bugs for fun and profit!

If some member functions of some classes could safely be called through a
null pointer, it seems like it would become very easy to forget to check
for null when you should be checking, and introduce new bugs into your code.

Received on 2024-10-31 19:27:32