Bug 10192 – Fixed size array initialization inconsistency between DeclDefs scope and statement scope

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2013-05-28T04:39:20Z
Last change time
2020-05-15T03:42:55Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2013-05-28T04:39:20Z
I think it's not OK to accept x3 assignment and refuse the a2 assignment: struct Foo { immutable(char)[4] bar; } Foo x1 = { "AA" }; // No error. immutable(char)[4] a1 = "AA"; // No error. void main() { Foo x2 = { "AA" }; // No error. Foo x3 = Foo("AA"); // No error. immutable(char)[4] a2 = "AA"; // Error: lengths don't match // for array copy, 4 = 2 } Kenji Hara answers: http://forum.dlang.org/post/[email protected] > This is known static array initializing inconsistency between > DeclDefs scope and statement scope. I think it is a bug. See also, where I say that I think all of those five cases should be reported as bugs: http://d.puremagic.com/issues/show_bug.cgi?id=3849
Comment #1 by pro.mathias.lang — 2020-05-15T03:42:55Z
Closing as duplicate. While this bug is much older and hence the other one should normally be marked duplicate, issue 19095 has a slightly better title, more discussion, and a PR attached to it. *** This issue has been marked as a duplicate of issue 19095 ***