Bug 7485 – Incorrect BigInt Error Message

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-02-11T12:13:00Z
Last change time
2012-06-13T04:25:32Z
Keywords
diagnostic
Assigned to
nobody
Creator
paul.d.anderson

Comments

Comment #0 by paul.d.anderson — 2012-02-11T12:13:18Z
When I try to compile this code: public struct Test1 { BigInt maxCoefficient = (BigInt(10)^^9 )- 1; } The error message is: src\phobos\std\internal\math\biguintx86.d(306): Error: asm statements cannot be interpreted at compile time. I don't know if the code should actually compile, but the error message is not helpful
Comment #1 by paul.d.anderson — 2012-02-11T12:24:00Z
public struct Test1 { BigInt maxCoefficient = (BigInt(10)^^9 )- 1; // line 1 } If I change line 1 to: BigInt maxCoefficient = BigInt(10)^^9 - 1; // remove parens It crashes the compiler.
Comment #2 by paul.d.anderson — 2012-02-11T12:28:42Z
I was mistaken about the compiler crashing. It does crash on that line in my code but not in the stripped-down test case.
Comment #3 by smjg — 2012-02-12T05:26:36Z
That's still not the error message I get at all (2.057, Win32): ----- C:\Users\Stewart\Documents\Programming\D\Tests\bugs>dmd bz7485.d bz7485.d(2): Error: undefined identifier BigInt ----- Please, always post a complete, self-contained testcase, and the full output from that testcase. Anyway, adding the necessary import gives for me: ----- bz7485.d ----- import std.bigint; public struct Test1 { BigInt maxCoefficient = (BigInt(10)^^9 )- 1; } ---------- C:\Users\Stewart\Documents\Programming\D\Tests\bugs>dmd bz7485.d d:\dmd2\windows\bin\..\..\src\phobos\std\internal\math\biguintx86.d(306): Error: asm statements cannot be interpreted at compile time d:\dmd2\windows\bin\..\..\src\phobos\std\internal\math\biguintcore.d(434): called from here: multibyteShl(result[words..words + this.data.length],this.data,bits) d:\dmd2\windows\bin\..\..\src\phobos\std\internal\math\biguintcore.d(692): called from here: result.opShl(cast(ulong)(evenbits + firstnonzero * 8u * 4u) * y) d:\dmd2\windows\bin\..\..\src\phobos\std\bigint.d(188): called from here: pow(this.data,u) d:\dmd2\windows\bin\..\..\src\phobos\std\bigint.d(188): called from here: this.data.opAssign(pow(this.data,u)) d:\dmd2\windows\bin\..\..\src\phobos\std\bigint.d(250): called from here: r.opOpAssign(y) bz7485.d(4): called from here: BigInt(BigUint([10u]),false).opBinary(9) bz7485.d(4): called from here: BigInt(BigUint([10u]),false).opBinary(9) ---------- It seems to me it's a combination of two things: - in certain circumstances, it fails to give this CTFE call backtrace (what compiler version are you using?) - the implementation of power on BigInt relies on inline assembly, thereby preventing it working with CTFE. A testcase for the complier crashing might still be useful. http://pr.stewartsplace.org.uk/d/bugreport.html might help you with creating one.
Comment #4 by clugdbug — 2012-06-13T04:25:32Z
I can't see any bug here. The error message is correct.