const struct not accepted as initializer by dmd 2.002
torhu
no at spam.invalid
Sat Jul 14 17:14:32 PDT 2007
torhu wrote:
> Reposting from D.learn, since there were no answers there.
>
> ---
> struct Inner
> {
> int value;
> }
>
> struct Outer {
> //const(Inner) i; // this fixes it, but is not valid in D 1.0
> Inner i;
> }
>
> const Inner ic = { 5 }; // const or invariant here makes no difference
>
> Outer outer = {
> i: ic // line 14
> //i: { 5 } // this is allowed
> };
> ---
> c:\prog\test\D>dmd -c test
> test.d(14): Error: non-constant expression cast(Inner)ic
> ---
>
> Since the value of ic is fixed at compile time, shouldn't it be
> equivalent to a literal?
Filed as bug #1342.
More information about the Digitalmars-d
mailing list