#1382 FieldMatrix does not get zero initialized with empty constructor
Metadata
Property | Value |
---|---|
Reported by | Markus Blatt (markus@dr-blatt.de) |
Reported at | Oct 24, 2013 15:59 |
Type | Bug Report |
Version | 2.2 |
Operating System | Unspecified / All |
Last edited by | Markus Blatt (markus@dr-blatt.de) |
Last edited at | Oct 30, 2013 10:17 |
Closed by | Markus Blatt (markus@dr-blatt.de) |
Closed at | Oct 30, 2013 10:17 |
Closed in version | Unknown |
Resolution | Not a bug |
Comment | It seems like I was again fooled by the inconsistencies of C++. The elements of std::array get default constructed. For non-pod types that are zero initialized with the default constructor, we have the exspected behaviour. This is also the case for FieldVector. (For pods this is a different story of course. |
Description
This is kind of a followup to FS 1322. As I read that task, it aimed at FieldMatrix being zero initialized when using the empty constructor. Unfortunately, this was not achieved by the patches provided.
The problem is FieldMatrix contains a std::array of FieldVectors. std:array stores its data in regular field and does generated default constructors (at least when using g++-4.4). Therefore the empty constructor of FieldVector is never called and the memory is not zero initialised (other than by chance).
This can only be worked around by explicitly calling e.g. std::fill on the std::array. I am not sure whether one wants do this, though.