D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10192 - Fixed size array initialization inconsistency between DeclDefs scope and statement scope
Summary: Fixed size array initialization inconsistency between DeclDefs scope and stat...
Status: RESOLVED DUPLICATE of issue 19095
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2013-05-28 04:39 UTC by bearophile_hugs
Modified: 2020-05-15 03:42 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2013-05-28 04:39:20 UTC
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/akeivrewkkhjuapbngel@forum.dlang.org

> 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 Mathias LANG 2020-05-15 03:42:55 UTC
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 ***