C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Rust vs C/C++ vs C++ Superset

From: Jarrad Waterloo <descender76_at_[hidden]>
Date: Wed, 28 Sep 2022 18:13:48 -0400
*I think the issue here is how limited this can be. The compiler cannot
doanything with:int &f(int &);int &f(){ int i; return f(i);}*

That is what the original lifetime extension attribute proposal is for and
the work that Clang is working on with their improved attributes.
As mentioned in "F43 direct dangling reduction", even though trivial, it is
always wrong, a missed teaching opportunity and a little bit embarrassing.
The fact that it is already fixed in the C++23 release is wonderful news;
definitely a step in the right direction.














On Wed, Sep 28, 2022 at 3:10 PM Thiago Macieira via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Wednesday, 28 September 2022 09:46:14 PDT Jarrad Waterloo via
> Std-Proposals
> wrote:
> > Agreed, I mentioned that in the F43 direct dangling reduction attachment.
> > There is no scenario in which that is ever good. It is always bad.
> > Making the compiler more complex to report that as an error doesn't make
> the
> > language more complex. We would just be making the compiler take more
> > responsibility for the stack which it is already responsible for. The
> > compiler doesn't even have to look outside the function to see that it is
> > wrong, since it is a direct local instead of an indirect one.
>
> I think the issue here is how limited this can be. The compiler cannot do
> anything with:
>
> int &f(int &);
> int &f()
> {
> int i;
> return f(i);
> }
>
> It cannot know what f(int&) does, and whether the reference it returns is
> always that of the argument.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel DCAI Cloud Engineering
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2022-09-28 22:14:00