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

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

Date: Tue, 30 Apr 2013 06:12:06 +0000

To: Tomi Ollila

Cc:, Vladimir Marek

From: Kim Minh Kaplan

Vladimir Marek writes:

> Well, a) standards says that
> A temporary bound to a reference parameter in a function call (5.2.2)
> persists until the completion of the full expression containing the call
> (you can find the message all over the net, but I can't find actual link
> to the standard :-/)

The january 2012 working draft:

    12.2 Temporary objects [class.temporary]

    1 Temporaries of class type are created in various contexts: binding a
    reference to a prvalue (8.5.3), returning a prvalue (6.6.3) […]

    3 When an implementation introduces a temporary object of a class that
    has a non-trivial constructor (12.1, 12.8), it shall ensure that a
    constructor is called for the temporary object. Similarly, the
    destructor shall be called for a temporary with a non-trivial destructor
    (12.4). Temporary objects are destroyed as the last step in evaluating
    the full-expression (1.9) that (lexically) contains the point where they
    were created.

Kim Minh.