C++ Logo


Advanced search

Re: [std-proposals] Relocation in C++

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 02 May 2022 21:31:48 -0700
On Monday, 2 May 2022 13:50:22 PDT Lénárd Szolnoki via Std-Proposals wrote:
> "It is implementation-defined whether the lifetime of a parameter ends
> when the function in which it is defined returns or at the end of the
> enclosing full-expression."

In other words, this function could return a dangling pointer?

const char *f(std::string s)
    return s.begin();

that's messed up.
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

Received on 2022-05-03 04:31:50