On 4 August 2011 10:29, Miles Bader wrote:
> Jonathan Wakely <[email protected]> writes:
>>> "g++ -Wall -Wextra ..." should flag a warning on the following code
>>> but does not.
>>
>> Thanks for the apology, but it should still be reported to bugzilla
>> not to this list.
>
> BTW, it should only warn if given -Weffc++, right?
No, returning a reference to a local variable is always wrong, not
only because Meyers says so.
We warn for this unconditionally, without any -W option:
struct XYZ { };
XYZ& f() { XYZ x; return x; }
We just don't do it when the reference doesn't bind directly to the
local, as in the earlier examples, because it's harder.