Bug 18416 – Different Typedef share addresses of static arrays

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2018-02-11T01:31:57Z
Last change time
2024-12-13T18:57:01Z
Assigned to
No Owner
Creator
Alex
Moved to GitHub: dmd#19387 →

Comments

Comment #0 by sascha.orlov — 2018-02-11T01:31:57Z
Defining two Typedefs with different cookies, based on a struct with a static array, leads to different types, which shares the static array. /// --- code --- /// import std.typecons; import std.traits; static assert(!is(MyEA == MyEB)); static assert(!is(MyEA == E)); static assert(!is(MyEB == E)); void main() { MyEA ea; MyEB eb; eb.tarr.length = 4; assert(ea.tarr.ptr != eb.tarr.ptr); // line 14 assert(ea.tarr.length != eb.tarr.length); // line 15 } struct T { size_t i; } struct E { size_t i; static T[] tarr; } alias MyEA = Typedef!(E, E.init, "A"); alias MyEB = Typedef!(E, E.init, "B"); /// --- code ends --- /// Line 14 and 15 yields both an error, which is unexpected. See also https://forum.dlang.org/thread/[email protected]
Comment #1 by robert.schadek — 2024-12-13T18:57:01Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19387 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB