microsoft/qsharp-runtime

QirArray::buffer: Proper alignment is not guaranteed.

kuzminrobin opened this issue · 1 comments

This line does not guarantee the proper alignment of the buffer pointed to by the QirArray::buffer. The C++ standard allows the allocation to be 1-byte aligned, 2-byte aligned, etc., which does not have to work for 4-byte values, 8-byte-values, etc.
In the best case the non-properly aligned buffer can result in a slower access (which I believe is the case on the x86 architecture). But in the worst case the access can result in an unexpected value returned/written. For example, on some architectures, reading a 2-byte value (16-bit value) starting at an even address and starting at address {even + 1} returns the same value (covering the addresses even and {even + 1}), i.e. the least significant address bit is ignored by hardware when accessing a 2-byte value.
The same is applicable to this line, this line.

Not applicable any more after migration to QIR RT in Rust. Closing.