[Issue 19916] union member access should be un- at safe

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed May 29 18:01:00 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19916

--- Comment #4 from Manu <turkeyman at gmail.com> ---
union U
{
  int x = 10;
  float f = void;
  NotAPointer np = void;
}
U u;

float r = 10.0 + u.f; // <- f is uninitialised, r is junk

np.callMethod(); // <- np is not a pointer, but still uninitialised, certain
crash

etc.

Any access to a union member may interact with uninitialised memory.
Accessing uninitialised memory is a memory safety issue.

--


More information about the Digitalmars-d-bugs mailing list