Thread overview | ||||||
---|---|---|---|---|---|---|
|
March 19, 2013 initializing const(Date) | ||||
---|---|---|---|---|
| ||||
This used to work but now in 2.062 it causes ctfe error. Any suggested workaround? http://dpaste.dzfl.pl/f1a8c2f5 ------------------------------------- import std.datetime; const(Date) DefaultDate = Date(1929, 10, 29); void main() { } ------------------------------------- Compilation output: /opt/compilers/dmd2/include/std/datetime.d(13542): Error: Internal Compiler Error: CTFE literal cast(short)1 dmd: ctfeexpr.c:353: Expression* copyLiteral(Expression*): Assertion `0' failed. Thanks Dan |
March 19, 2013 Re: initializing const(Date) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dan | On Tuesday, 19 March 2013 at 16:35:22 UTC, Dan wrote:
> This used to work but now in 2.062 it causes ctfe error.
> Any suggested workaround?
This seems to work:
Date defDate() pure { return Date(1929, 10, 29); }
const(Date) DefaultDate = defDate();
Assuming you wanted to avoid a initializing inside a static this().
|
March 19, 2013 Re: initializing const(Date) | ||||
---|---|---|---|---|
| ||||
Posted in reply to cal | On Tuesday, 19 March 2013 at 17:04:01 UTC, cal wrote:
> On Tuesday, 19 March 2013 at 16:35:22 UTC, Dan wrote:
>> This used to work but now in 2.062 it causes ctfe error.
>> Any suggested workaround?
>
> This seems to work:
Or:
const(Date) DefaultDate = { return Date(1929,10,10); }();
although this is getting cryptic.
|
March 19, 2013 Re: initializing const(Date) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dan | On Tuesday, March 19, 2013 17:35:20 Dan wrote: > This used to work but now in 2.062 it causes ctfe error. Any suggested workaround? > > http://dpaste.dzfl.pl/f1a8c2f5 > ------------------------------------- > import std.datetime; > const(Date) DefaultDate = Date(1929, 10, 29); > void main() { > > } > ------------------------------------- > > Compilation output: > /opt/compilers/dmd2/include/std/datetime.d(13542): Error: > Internal Compiler Error: CTFE literal cast(short)1 > dmd: ctfeexpr.c:353: Expression* copyLiteral(Expression*): > Assertion `0' failed. It appears to work if you just do const defaultDate = Date(1929, 10, 29); But please report this as a regression: http://d.puremagic.com/issues - Jonathan M Davis |
Copyright © 1999-2021 by the D Language Foundation