C++ Logo

std-proposals

Advanced search

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

From: Thiago Macieira <thiago_at_[hidden]>
Date: Wed, 28 Sep 2022 12:10:14 -0700
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

Received on 2022-09-28 19:10:16