public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/44859] New: missed warning: returning reference to temporary
@ 2010-07-07 14:52 joachim dot reichel at gmx dot de
2010-07-07 15:04 ` [Bug c++/44859] " redi at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: joachim dot reichel at gmx dot de @ 2010-07-07 14:52 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1373 bytes --]
struct Base1 {};
struct Derived1 : public Base1 {};
const Base1& f1() { Base1 x; return x; }
const Base1& f2() { return Base1(); }
const Base1& f3() { Derived1 x; return x; }
const Base1& f4() { return Derived1(); }
struct Base2 { int m_foo; };
struct Derived2 : public Base2 {};
const Base2& f5() { Base2 x; return x; }
const Base2& f6() { return Base2(); }
const Base2& f7() { Derived2 x; return x; }
const Base2& f8() { return Derived2(); }
g++ emits a warning for all cases (either "reference to local variable x
returned" or "returning reference to temporary"), except for the last case f8.
Adding -Wall -Wextra does not change anything. Apparently this seems to be
caused by the cast of a temporary (in contrast to the local variable in f7) to
a non-empty base class.
It would be nice if g++ would warn for this case as well.
--
Summary: missed warning: returning reference to temporary
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: joachim dot reichel at gmx dot de
GCC build triplet: x64_64-unknown-linux-gnu
GCC host triplet: x64_64-unknown-linux-gnu
GCC target triplet: x64_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44859
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/44859] missed warning: returning reference to temporary
2010-07-07 14:52 [Bug c++/44859] New: missed warning: returning reference to temporary joachim dot reichel at gmx dot de
@ 2010-07-07 15:04 ` redi at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu dot org @ 2010-07-07 15:04 UTC (permalink / raw)
To: gcc-bugs
--
redi at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |diagnostic
Last reconfirmed|0000-00-00 00:00:00 |2010-07-07 15:04:04
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44859
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-07-07 15:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-07 14:52 [Bug c++/44859] New: missed warning: returning reference to temporary joachim dot reichel at gmx dot de
2010-07-07 15:04 ` [Bug c++/44859] " redi at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).