Nov. 8, 2022
11:39 p.m.
On 11/8/22 06:28, Clive D.W. Feather via tz wrote:
You could replace the assignment by a memcpy. Assignment via unsigned chars (which is what memcpy does) are exempt from the undefined behaviour.
As I understand it, that exemption is for using memcpy to copy a trap representation. There's no similar exemption for using memcpy to copy uninitialized data; for example, the following function has undefined behavior: int y; void f(void) { int x; memcpy(&y, &x, sizeof y); } If I'm right, we can't get by simply by replacing the assignment with memcpy.