Comment #0 by paul.d.anderson — 2015-07-03T16:19:26Z
The following code fails to compile and responds with the given error message. Varying the "plusTwo" function doesn't work; as long as there is an arithmetic operation the error occurs.
It seems to mean that there is no way to modify a BigInt at compile time. This seriously limits the usability of the type.
enum BigInt test1 = BigInt(123);
enum BigInt test2 = plusTwo(test1);
public static BigInt plusTwo(in BigInt n)
{
return n + 2;
}
void main()
{
}
Error message:
C:\D\dmd2\windows\bin\..\..\src\phobos\std\internal\math\biguintx86.d(226): Error: asm statements cannot be interpreted at compile time
Error occurs with dmd 2.067.1 for 32-bit Windows. Does not occur with Windows 64-bit version
Comment #1 by hsteoh — 2015-07-03T20:20:17Z
Currently, BigInt is implemented as a runtime library type that uses asm optimizations, which cannot be interpreted in CTFE. Marking this as an enhancement request to add CTFE support to BigInt.
Comment #2 by paul.d.anderson — 2015-07-07T22:23:05Z
Could we add a version or a compiler flag that would force use the .biguintnoasm version for the x86 also? That seems like an innocuous change that could be easily implemented.
Paul
Comment #3 by paul.d.anderson — 2015-07-07T22:23:58Z
I changed the hardware setting from x86_64 to x86.
Paul
Comment #4 by gassa — 2015-07-08T13:48:44Z
Perhaps on x86, the compiler could do something like the following when instantiating BigInt:
-----
if (__ctfe)
{
// use biguintnoasm
}
else
{
// use biguintx86
}
-----
Comment #5 by b2.temp — 2018-01-14T18:20:21Z
*** Issue 17003 has been marked as a duplicate of this issue. ***
Comment #6 by b2.temp — 2018-01-14T18:20:36Z
*** Issue 17095 has been marked as a duplicate of this issue. ***