std::array assignment causes hardfault
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Arm Embedded Toolchain |
New
|
Undecided
|
Unassigned |
Bug Description
I asked this question on the forum. I got no responses so I'm trying it here:
When a std::array is assigned to another it may result in a hardfault ('usage' I think). The code the compiler generates to perform the copy uses 32-bit registers to transfer the data. If the source array or destination are not on a 32-bit boundary, a hardfault will occur. I thought the compiler always put class members on 32-bit boundaries, however, these std:array can actually be 16-bit aligned.
The following code is likely to generate a hardfault:
Compiler:
arm-none-
class ArrayTest
{
public:
ArrayTest() {}
~ArrayTest()
{
}
void MakeEqual()
{
mArrayA = mArrayB;
}
private:
std:
std:
};
Calling MakeEqual() will likely cause a hardfault if either array is on a 16-bit boundary instead of a 32-bit boundary.
Is this a defect, or is it the programmers responsibility to ensure std:arrays are on 32-bit boundaries?
If this is a defect, should it be logged here or in GCC bugzilla?
Thanks