const->immutable array argument?
Daniel Murphy
yebblies at nospamgmail.com
Tue Sep 20 08:08:44 PDT 2011
"Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message
news:op.v13w8td2eav7ka at localhost.localdomain...
> On Tue, 20 Sep 2011 07:33:20 -0400, bearophile <bearophileHUGS at lycos.com>
> wrote:
>
>> void foo(const ref int[5] a) {}
>> void main() {
>> immutable int[5] arr;
>> foo(arr); // Error?
>> }
>
> The complaint from the compiler is that cast(const(int[5u])) arr is not an
> lvalue.
It's a bug, the compiler shouldn't be inserting a cast when the value
implicitly converts. It's also a bug when the compiler tries to optimise
away the variable to a literal when passing by reference, I've got a patch
for this I haven't written up yet.
More information about the Digitalmars-d-learn
mailing list