[email protected] 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.
Comment #1 by ag0aep6g — 2018-03-12T10:07:19Z
(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.
Comment #2 by bugzilla — 2018-03-13T06:10:47Z
(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.
(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.
Comment #5 by github-bugzilla — 2018-03-23T03:40:32Z