Watch, Follow, &
Connect with Us

Please visit our new home

Public Report
Report From: Delphi-BCB/Compiler/C++/Front End/Initialization    [ Add a report in this area ]  
Report #:  83751   Status: Closed
Value-initialization: arrays should have each element value-initialized
Project:  C++Builder Build #:  6.21.3615.26516
Version:    14.0 Submitted By:   Niels Dekker
Report Type:  Basic functionality failure Date Reported:  4/11/2010 7:54:33 AM
Severity:    Serious / Highly visible problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   275893
Resolution: Fixed (Resolution Comments) Resolved in Build: : 15.0.3860.33047
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 10
Thanks for fixing issue 51854, "Value-initialization: POD struct should be zero-initialized", I can confirm that I'm no longer able reproduce the bug, using the latest version of your compiler (Embarcadero C++ 6.21, 2010).

However, your compiler appears to have a similar problem with regard to built-in arrays. The C++ Standard (2003) says that to value-initialize an array means that each element is value-initialized ([dcl.init]). However, when I try to value-initialize an array, the compiler gives me a warning instead: "W8039 Constructor initializer list ignored".  And when I do so for an array of integers, they remain uninitialized. (Or at least, they remain non-zero.) When I run the program presented in "Steps to Reproduce", it halts at the first assert, saying "Assertion failed:[0] == 0"

Please fix it!
Steps to Reproduce:
#include <cassert>

  struct TWrapper {
    int data[2];
    TWrapper() : data() {}

  int main() {
    TWrapper wrapper;
    // Asserts should not fail, but they do!
    assert([0] == 0);
    assert([1] == 0);

    // Should return zero, but it does not.
    return[0] +[1];
As a workaround, people could use boost::value_initialized<T[N]>, from Fernando Cacciola:

But of course, it would be preferable to get value-initialization "out of the box", straight from the compiler.

Tomohiro Takahashi at 4/11/2010 7:37:47 PM -
I confrmed your issue. I will open this report after maintenance of internal tracking system.

Niels Dekker at 4/12/2010 12:37:58 PM -
Thanks for your reply, Tomohiro. For your information, I just wrote a test which verifies the implementation of value-initialization for an large number of types, including arrays, classes, structs and unions. The test is to be included with Boost version 1.44.0, but a preliminary version is already at  

While the file will become part of the Boost Config component, it can also be used without having Boost installed. (It does not depend on any other Boost file.) For example, by including the file in a little console application:

  #include "boost_no_com_value_init.ipp"
  #include <cassert>

  int main() {
    const int num_failures =
    assert(num_failures == 0);
    return num_failures;

Please tell me if you have any comment, remark or suggestion regarding this test.

Server Response from: ETNACODE01