ag0aep6g@gmail.com writes: //////////////////////////////// test.d //////////////////////////////// @safe: struct Victim { bool alive = true; ~this() { alive = false; } } align(1) struct Unaligned { align(1): ubyte filler; Victim* p; } pragma(msg, Unaligned.sizeof); void main() { enum N = 100; Unaligned[N] hosts; foreach (n; 0..N) { version (original) hosts[n].p = new Victim; else version (variation1) hosts[n] = Unaligned(0, new Victim); else version (variation2) { Unaligned u = { p: new Victim }; hosts[n] = u; } else static assert(false); assert(hosts[n].p.alive); } // Unaligned.p is invisible to the GC due to alignment void trustedCollect() @trusted { import core.memory; GC.collect(); } trustedCollect(); foreach (n; 0..N) assert(hosts[n].p.alive); // Dangling pointer! } //////////////////////////////////////////////////////////////////////// These should all fail with the same error: dmd -version=original test.d dmd -version=variation1 test.d dmd -version=variation2 test.d The different versions effectively do the same thing, just with different syntax.
(In reply to Walter Bright from comment #0) > ag0aep6g@[...].com writes: Please don't give away people's email addresses like that. It doesn't matter too much for me, because that's my D address, but generally it's not a nice thing to do.
(In reply to ag0aep6g from comment #1) > (In reply to Walter Bright from comment #0) > > ag0aep6g@[...].com writes: > > Please don't give away people's email addresses like that. It doesn't matter > too much for me, because that's my D address, but generally it's not a nice > thing to do. Sorry about that, but I just copy pasted from the public page: https://issues.dlang.org/show_bug.cgi?id=15399 I.e. your email address appears with every comment you write, including the one this is in reply to. You might want to check your bugzilla profile.
https://github.com/dlang/dmd/pull/8019
(In reply to Walter Bright from comment #2) > (In reply to ag0aep6g from comment #1) [...] > Sorry about that, but I just copy pasted from the public page: [...] > I.e. your email address appears with every comment you write, including the > one this is in reply to. You might want to check your bugzilla profile. Huh. I thought I had set the name properly. Sorry for lashing out. Bugzilla didn't already make it public, though. It's smart enough to remove the domain part in replies and on truly public pages (i.e. when you're not logged in). But then again, <https://forum.dlang.org/group/issues> shows all Bugzilla activity to the public, including everyone's addresses. So that's that.
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/3afbfb2c1b6328c18bdfd1f122091a74e22f9d69 fix Issue 18597 - more unsafe unaligned pointer errors https://github.com/dlang/dmd/commit/a0764d9ea0e7b3132d0a362b2f32a6e74e6e76e0 Merge pull request #8019 from WalterBright/fix18597 fix Issue 18597 - more unsafe unaligned pointer errors merged-on-behalf-of: Mike Franklin <JinShil@users.noreply.github.com>