C++ Logo

std-proposals

Advanced search

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

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Mon, 28 Oct 2024 08:24:18 +0100
Hi Jens, as far as I understand the notion of "discarded value expression" made it unclear, whether (*nullptr) was UB.   According to https://eel.is/c++draft/expr.ref#2 "For the first option (dot), if the id-expression names a static member or an enumerator, the first expression is a discarded-value expression ([expr.context])" And according to https://eel.is/c++draft/expr.context#2 "In some contexts, an expression only appears for its side effects. Such an expression is called a discarded-value expression."   So the result of (*nullptr) was irrelevant with the previous wording, only the side effects mattered. And side effects were mostly intended ones, which had to be fulfilled (e.g. a function being called), it was at least unclear, if just a non-overloaded dereferencing (which would lead to UB for nullptr, but has no effect on any valid target) is a side effect. The change made it clear that (*nullptr) always leads to UB. You are saying, it was clear beforehand? Best, Sebastian   -----Ursprüngliche Nachricht----- Von:Jens Maurer via Std-Proposals <std-proposals_at_[hidden]> Gesendet:Mo 28.10.2024 07:58 Betreff:Re: [std-proposals] Calling methods on a nullptr An:std-proposals_at_[hidden]; CC:Jens Maurer <jens.maurer_at_[hidden]>; > 2823 made it clear that (*nullptr) is always UB. What would the result of *nullptr be, with the previous wording? Jens  

Received on 2024-10-28 07:24:44