public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49372] New: Temporaries evaluated for arguments of a default constructors of array elements not destructed properly (?)
@ 2011-06-11 13:27 schaub.johannes at googlemail dot com
  2011-06-11 13:47 ` [Bug c++/49372] " schaub.johannes at googlemail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: schaub.johannes at googlemail dot com @ 2011-06-11 13:27 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Temporaries evaluated for arguments of a default
                    constructors of array elements not destructed properly
                    (?)
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: schaub.johannes@googlemail.com


This testcase outputs a surprising result:

struct A {
  A() { std::cout << "C" << std::endl; }
  ~A() { std::cout << "D" << std::endl; }
};

struct B {
  B(A const& a = A()) { }
};

typedef B array[2];

int main() {
  array{};
}

GCC prints "CCDD". I would have expected "CDCD", as it seems that is the intent
of the wording in the spec (FDIS). The FDIS however seems to be contradicting
here, but it appears to me that GCC should better print "CDCD", so as to follow
the intent. 

Originated from
http://stackoverflow.com/questions/6315670/when-an-array-is-created-by-a-subexpression-what-happens-with-the-temporaries-th
.


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

end of thread, other threads:[~2023-05-08 12:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-11 13:27 [Bug c++/49372] New: Temporaries evaluated for arguments of a default constructors of array elements not destructed properly (?) schaub.johannes at googlemail dot com
2011-06-11 13:47 ` [Bug c++/49372] " schaub.johannes at googlemail dot com
2012-12-10 11:07 ` ktietz at gcc dot gnu.org
2012-12-10 13:15 ` redi at gcc dot gnu.org
2012-12-10 13:42 ` ktietz at gcc dot gnu.org
2012-12-10 16:43 ` schaub.johannes at googlemail dot com
2023-05-08 12:58 ` ppalka 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).