value-initialization
Andrew Koenig
ark@research.att.com
Fri Apr 23 12:04:00 GMT 1999
At its Dublin meeting in April, 1999, the C++ standards committee
agreed to strengthen the requirements on the initial value of
expressions of the form T(), where class T does not have a
user-defined constructor.
Because any implementation that meets the revised requirements also
meets the present requirements, and because the revision makes some
programs significantly easier to write, I would like to urge you to
make egcs follow the revised requirements as soon as possible, and to
let the C++ community know promptly once this has happened.
Here is an example of a program whose behavior is guaranteed by the
revised definition, but not by the present standard (or by egcs):
// This test is not guaranteed to detect failure, but it's pretty likely.
#include <iostream>
struct A { A() { } };
struct T {
int a[1000000];
A aa;
};
int main()
{
T t = T();
for (int i = 0; i < 1000000; ++i)
if (t.a[i]) {
std::cout << "t.a[" << i << "]=" << t.a[i] << std::endl;
return 1;
}
return 0;
}
If you need any additional information, please let me know.
Regards,
Andrew Koenig
ark@research.att.com
Project Editor,
C++ Standards Committee
More information about the Gcc-bugs
mailing list