Date: Mon, 10 Feb 2025 12:47:43 +0100
pon., 10 lut 2025 o 11:26 Tiago Freire via Std-Proposals
<std-proposals_at_[hidden]> napisał(a):
>
> Can you write such an application and run it?
>
>
>
> Sure, it’s invalid. So what?
>
>
>
> Stating that it is “not valid C++” it is not useful, in general you don’t try to write invalid code intentionally.
>
> But it happens anyways, and if you can do it by writing plain C++, and it spits out an application that you can run in a computer.
>
>
>
> Yeah, it may blow up as you run it. You can call it “invalid”… ok, the same way you can call it a “fish”.
>
> But it has never stopped such an application from existing or even running.
>
> And that was the point, it is not stopping you from writing invalid code.
>
> So, it is better that when you change something that you know where to put the checks right? So that you don’t accidentally write that invalid code?
>
>
Using the same logic I can't assume that the reference is to `int` and
not to `std::string` as you can mess up dynamic types too.
Or reference point to some uninitialized memory.
All invariants of C++ can be subverted (even compile consts could be
altered by toying with memory maps) but this do not
change facts that are very useful.
If you have null ref then it means your code is broken elsewhere,
if you have null ptr then you need to consider if it should be
or not be null here in the first place.
>
>
>
> From: Std-Proposals <std-proposals-bounces_at_[hidden]> On Behalf Of Sebastian Wittmeier via Std-Proposals
> Sent: Monday, February 10, 2025 11:06 AM
> To: std-proposals_at_[hidden]
> Cc: Sebastian Wittmeier <wittmeier_at_[hidden]>
> Subject: Re: [std-proposals] Possible deprecation of -> operator
>
>
>
> A buggy program in general can be valid.
>
> A UB program is not valid.
>
>
>
> A pointer can be nullptr, as long as it is never dereferenced.
>
> A reference cannot refer to an object with an address of nullptr.
>
> Such a program is not a valid C++ program.
>
>
> -----Ursprüngliche Nachricht-----
> Von: Tiago Freire <tmiguelf_at_[hidden]>
> Gesendet: Mo 10.02.2025 10:44
> Betreff: RE: [std-proposals] Possible deprecation of -> operator
> An: std-proposals_at_[hidden];
> CC: Sebastian Wittmeier <wittmeier_at_[hidden]>;
>
> > It is not possible to write a valid C++ program, where the address of a reference is the nullptr.
>
>
> Never heard of that. I guess that depends on your definition of valid, if writing bugs is not a “valid” C++ program, but there’s nothing stopping you from writing them.
>
> And it has never stopped me from catching exactly this bug many times. I’ve even given you an example on how to do exactly this on my previous email.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
<std-proposals_at_[hidden]> napisał(a):
>
> Can you write such an application and run it?
>
>
>
> Sure, it’s invalid. So what?
>
>
>
> Stating that it is “not valid C++” it is not useful, in general you don’t try to write invalid code intentionally.
>
> But it happens anyways, and if you can do it by writing plain C++, and it spits out an application that you can run in a computer.
>
>
>
> Yeah, it may blow up as you run it. You can call it “invalid”… ok, the same way you can call it a “fish”.
>
> But it has never stopped such an application from existing or even running.
>
> And that was the point, it is not stopping you from writing invalid code.
>
> So, it is better that when you change something that you know where to put the checks right? So that you don’t accidentally write that invalid code?
>
>
Using the same logic I can't assume that the reference is to `int` and
not to `std::string` as you can mess up dynamic types too.
Or reference point to some uninitialized memory.
All invariants of C++ can be subverted (even compile consts could be
altered by toying with memory maps) but this do not
change facts that are very useful.
If you have null ref then it means your code is broken elsewhere,
if you have null ptr then you need to consider if it should be
or not be null here in the first place.
>
>
>
> From: Std-Proposals <std-proposals-bounces_at_[hidden]> On Behalf Of Sebastian Wittmeier via Std-Proposals
> Sent: Monday, February 10, 2025 11:06 AM
> To: std-proposals_at_[hidden]
> Cc: Sebastian Wittmeier <wittmeier_at_[hidden]>
> Subject: Re: [std-proposals] Possible deprecation of -> operator
>
>
>
> A buggy program in general can be valid.
>
> A UB program is not valid.
>
>
>
> A pointer can be nullptr, as long as it is never dereferenced.
>
> A reference cannot refer to an object with an address of nullptr.
>
> Such a program is not a valid C++ program.
>
>
> -----Ursprüngliche Nachricht-----
> Von: Tiago Freire <tmiguelf_at_[hidden]>
> Gesendet: Mo 10.02.2025 10:44
> Betreff: RE: [std-proposals] Possible deprecation of -> operator
> An: std-proposals_at_[hidden];
> CC: Sebastian Wittmeier <wittmeier_at_[hidden]>;
>
> > It is not possible to write a valid C++ program, where the address of a reference is the nullptr.
>
>
> Never heard of that. I guess that depends on your definition of valid, if writing bugs is not a “valid” C++ program, but there’s nothing stopping you from writing them.
>
> And it has never stopped me from catching exactly this bug many times. I’ve even given you an example on how to do exactly this on my previous email.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2025-02-10 11:47:58