DEV Community

Discussion on: Why do integral types get weirdly initialized inside of std::array in C++, and how can I fix it?

Collapse
 
pgradot profile image
Pierre Gradot

We can't answer without a minimal code that reproduces that the issue.

Collapse
 
baenencalin profile image
Calin Baenen

Literally just do std::array<NumericDatatype, 5> arr; /* Code to print. */ and you'll get similar results.

Collapse
 
pgradot profile image
Pierre Gradot • Edited

arr is not initialized. So its actual content is not specified.

The behavior you observe is normal: there are random values in the array.

Sometimes, random values look like something you expect (like : all bools are false) but this is pure coincidence.