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: unassig...@gcc.gnu.org
        ReportedBy: schaub.johan...@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
.

Reply via email to