I've just come across a potential issue with the field copy constructors. These just give the new field a reference to the existing data block, which we call checkData on if CHECK > 2.
Consider the following case
Field2D a;
a.allocate();
Field2D b(a);
In the copy constructor call to make b we will checkData on the data block of a. This has been allocated but it has not been initialised so the checkData output is undefined (i.e. it could throw or it could not).
I think the only ways to avoid this undefined behaviour would be to either remove the checkData call in copy constructors or to ensure allocate initialises the data block.
I've just come across a potential issue with the field copy constructors. These just give the new field a reference to the existing data block, which we call
checkDataon ifCHECK > 2.Consider the following case
In the copy constructor call to make
bwe willcheckDataon the data block ofa. This has been allocated but it has not been initialised so thecheckDataoutput is undefined (i.e. it could throw or it could not).I think the only ways to avoid this undefined behaviour would be to either remove the
checkDatacall in copy constructors or to ensureallocateinitialises the data block.