Bug 11156 – Refuse wrongly sized array assigned in C-style struct literal

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-01T18:35:05Z
Last change time
2024-12-13T18:12:11Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: dmd#18685 →

Comments

Comment #0 by bearophile_hugs — 2013-10-01T18:35:05Z
struct Foo { int[3] a; } void main() { Foo f1 = {[10, 20]}; // No error. Foo f2 = Foo([10, 20]); // Line 6, Error. } DMD 2.064 alpha gives: temp.d(6): Error: cannot implicitly convert expression ([10, 20]) of type int[] to int[3] I think D should accept both or refuse both. Probably it should refuse both. See also issue 481
Comment #1 by andrej.mitrovich — 2013-10-01T18:39:20Z
Also similar to Issue 3849.
Comment #2 by robert.schadek — 2024-12-13T18:12:11Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18685 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB