Bug 14449 – Cannot create structure with `inout` constructor at compile time

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-04-15T11:30:10Z
Last change time
2024-12-13T18:42:11Z
Assigned to
No Owner
Creator
Maksim Zholudev
Moved to GitHub: dmd#18975 →

Comments

Comment #0 by maximzms — 2015-04-15T11:30:10Z
In the following example `inout` constructor works for some types but fails for others. test.d: -------------------- struct Foo(T) { T[1] a; this(in T[] src) inout { a = src; } // <----- line 4 } enum fbool = Foo!bool([true]); // OK enum fint = Foo!int([1]); // OK enum flong = Foo!long([1]); // OK enum fchar = Foo!char(['1']); // OK enum fstring = Foo!string(["1"]); // Error enum ffloat = Foo!float([1]); // Error struct Boo { int a; } enum fstruct = Foo!Boo([Boo(1)]); // Error void main() {} -------------------- Output: -------------------- test.d(4): Error: array cast from const(string[]) to const(inout(string)[]) is not supported at compile time test.d(12): called from here: Foo(null).this(["1"]) test.d(4): Error: array cast from const(float[]) to const(inout(float)[]) is not supported at compile time test.d(13): called from here: Foo(nanF).this([1.00000F]) test.d(4): Error: array cast from const(Boo[]) to const(inout(Boo)[]) is not supported at compile time test.d(15): called from here: Foo(Boo(0)).this([Boo(1)]) --------------------
Comment #1 by robert.schadek — 2024-12-13T18:42:11Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18975 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB