public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60297] New: Temporary lifetime not extended by reference bound to POD member
@ 2014-02-21 4:30 potswa at mac dot com
2014-02-21 5:33 ` [Bug c++/60297] " potswa at mac dot com
0 siblings, 1 reply; 2+ messages in thread
From: potswa at mac dot com @ 2014-02-21 4:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60297
Bug ID: 60297
Summary: Temporary lifetime not extended by reference bound to
POD member
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: potswa at mac dot com
The resolution to DR 1651 seems inconsistently applied. This program should
print "check" before "destroy", but if the reference is bound to member "i"
instead of "np" the lifetime is not extended.
#include <iostream>
struct notpod {
~notpod() {}
};
struct noisy {
~noisy() { std::cout << "destroy\n"; }
};
struct cont {
noisy o;
notpod np;
int i;
};
int main() {
{
notpod && q = cont().np;
std::cout << "check\n";
} // cont::~cont here
{
int && i = cont().i;
// cont::~cont here; i is dangling.
std::cout << "check\n";
}
}
The problem may be broader than DR 1651 because the results are the same if
"const &" is substituted for "&&".
(Note, I submitted a trivial, somewhat similar bug yesterday but this issue is
completely unrelated, and it's "for real.")
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/60297] Temporary lifetime not extended by reference bound to POD member
2014-02-21 4:30 [Bug c++/60297] New: Temporary lifetime not extended by reference bound to POD member potswa at mac dot com
@ 2014-02-21 5:33 ` potswa at mac dot com
0 siblings, 0 replies; 2+ messages in thread
From: potswa at mac dot com @ 2014-02-21 5:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60297
--- Comment #1 from David Krauss <potswa at mac dot com> ---
Woops, I neglected to check a POD class type. Removing the destructor from
"notpod" has no effect. The condition seems to apply to all scalar types
instead.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-21 5:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-21 4:30 [Bug c++/60297] New: Temporary lifetime not extended by reference bound to POD member potswa at mac dot com
2014-02-21 5:33 ` [Bug c++/60297] " potswa at mac dot com
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).