Date: Tue, 18 Feb 2025 19:53:27 +0000
Actually the capability of detecting nullptr dereferences (or any invalid memory access in general) is built into pretty much all hardware nowadays. Detecting ALL nullptr references and throwing an exception would be entirely free on most machines (and in fact this is what the android java runtime does, unless they've changed it).
What's actually being proposed (checking only specific annotated dereferences) _would_ require individual checks, however. Or else the trap handler would have to consult a table to determine if the nullptr dereference it's just caught is one that was annotated and should throw or is an organic nullptr dereference and should "merely" create a crash dump and/or break into an attached debugger.
On 18 February 2025 16:05:42 GMT, Jason McKesson via Std-Proposals <std-proposals_at_[hidden]> wrote:
>On Tue, Feb 18, 2025 at 10:46 AM Filip via Std-Proposals
><std-proposals_at_[hidden]> wrote:
>>
>> What if dereferencing nullptr would not be an undefined behavior?
>
>"What if we made every program significantly slower by requiring the
>compiler to insert testing into every pointer dereference as well as
>exception logic?"
>
>No, thank you.
>--
>Std-Proposals mailing list
>Std-Proposals_at_[hidden]
>https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
What's actually being proposed (checking only specific annotated dereferences) _would_ require individual checks, however. Or else the trap handler would have to consult a table to determine if the nullptr dereference it's just caught is one that was annotated and should throw or is an organic nullptr dereference and should "merely" create a crash dump and/or break into an attached debugger.
On 18 February 2025 16:05:42 GMT, Jason McKesson via Std-Proposals <std-proposals_at_[hidden]> wrote:
>On Tue, Feb 18, 2025 at 10:46 AM Filip via Std-Proposals
><std-proposals_at_[hidden]> wrote:
>>
>> What if dereferencing nullptr would not be an undefined behavior?
>
>"What if we made every program significantly slower by requiring the
>compiler to insert testing into every pointer dereference as well as
>exception logic?"
>
>No, thank you.
>--
>Std-Proposals mailing list
>Std-Proposals_at_[hidden]
>https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2025-02-18 19:53:38