Re: [PATCH] don't store temporary value returned from c_str()

Subject: Re: [PATCH] don't store temporary value returned from c_str()

Date: Sat, 27 Apr 2013 08:53:33 -0300

To: Vladimir Marek, Tomi Ollila

Cc: notmuch@notmuchmail.org, Vladimir Marek

From: David Bremner


Vladimir Marek <Vladimir.Marek@Oracle.COM> writes:

>
> const char*
> string::c_str(void) {
> 	char buf[100];
>
> 	strcpy (buf, this->internal_representation);
> 	return buf;
> }

Isn't that undefined behavior, returning a pointer to a (non-static)
local variable?

d

Thread: