www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7485] New: Incorrect BigInt Error Message

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7485

           Summary: Incorrect BigInt Error Message
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: paul.d.anderson comcast.net



12:13:18 PST ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 11 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7485




12:24:00 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 11 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7485


Paul D. Anderson <paul.d.anderson comcast.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paul.d.anderson comcast.net



12:28:42 PST ---
I was mistaken about the compiler crashing. It does crash on that line in my
code but not in the stripped-down test case.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 11 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7485


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
                 CC|                            |smjg iname.com



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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 12 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7485


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |INVALID



I can't see any bug here. The error message is correct.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 13 2012