public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49528] New: g++ fails to destroy temporary object when subobject is used to initialize a reference
@ 2011-06-25  3:33 jason at gcc dot gnu.org
  2011-06-25  3:33 ` [Bug c++/49528] " jason at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2011-06-25  3:33 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49528

           Summary: g++ fails to destroy temporary object when subobject
                    is used to initialize a reference
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jason@gcc.gnu.org


I believe that r should point to a temporary int and the A temporary destroyed
at the end of the declaration statement rather than have its lifetime extended
to the end of the block.  In any case, never destroying it is clearly broken.

int d;
struct A
{
  int i;
  ~A() { ++d; };
};

int main()
{
  { const int &r = A().i; }
  if (d != 1)
    return 1;
}


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-06-27 20:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-25  3:33 [Bug c++/49528] New: g++ fails to destroy temporary object when subobject is used to initialize a reference jason at gcc dot gnu.org
2011-06-25  3:33 ` [Bug c++/49528] " jason at gcc dot gnu.org
2011-06-25  3:35 ` [Bug c++/49528] [4.6/4.7 regression] " jason at gcc dot gnu.org
2011-06-25  9:41 ` rguenth at gcc dot gnu.org
2011-06-26  0:52 ` jason at gcc dot gnu.org
2011-06-26 14:00 ` jason at gcc dot gnu.org
2011-06-27  1:07 ` [Bug c++/49528] [4.6 " jason at gcc dot gnu.org
2011-06-27 15:55 ` jakub at gcc dot gnu.org
2011-06-27 20:17 ` jason at gcc dot gnu.org
2011-06-27 20:19 ` jason at gcc dot gnu.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).