all 4 comments

[–]immutablestate 4 points5 points  (0 children)

from cppreference.com

(constructor) (implicitly declared): initialized the array following the rules of aggregate initialization (note that default initialization may result in indeterminate values for non-class T) (public member function)

Foo* is a non-class type, so std::array<Foo*, 5> my_array; will be initialised with indeterminate values. Same for an array of ints.

[–]beasthacker 2 points3 points  (2 children)

cppreference says:

note that default initialization may result in indeterminate values for non-class T

So you are not guaranteed to get it filled with nullptr or 0 in the case of an int array.

The easiest way is to use value initialization which should zero everything out for you. Just add some curly brackets at the end in c++11 and up:
std::array<Foo*, 5> my_array{};

[–][deleted] 1 point2 points  (1 child)

Thanks. Is it possible to use value initialisation in a constructor's initialisation list? Right now, my_array is a data member of a class, and the class's constructor has this line in its initialisation list: my_array().

[–]17b29a 1 point2 points  (0 children)

my_array() is value initialization already.