This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49372] New: Temporaries evaluated for arguments of a default constructors of array elements not destructed properly (?)
- From: "schaub.johannes at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 11 Jun 2011 13:27:19 +0000
- Subject: [Bug c++/49372] New: Temporaries evaluated for arguments of a default constructors of array elements not destructed properly (?)
- Auto-submitted: auto-generated
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
.