digitalmars.D.bugs - [Issue 18416] New: Different Typedef share addresses of static arrays
- d-bugmail puremagic.com (41/41) Feb 10 2018 https://issues.dlang.org/show_bug.cgi?id=18416
https://issues.dlang.org/show_bug.cgi?id=18416 Issue ID: 18416 Summary: Different Typedef share addresses of static arrays Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: sascha.orlov gmail.com 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/ceilfwjlagdbygudaesq forum.dlang.org --
Feb 10 2018