Thread overview
[Issue 9057] New: Non-constant expression error in biguintcore
[Issue 9057] Regression(Beta): Segfault or "Non-constant expression" error with local import
Nov 28, 2012
Don
Dec 10, 2012
Walter Bright
November 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9057

           Summary: Non-constant expression error in biguintcore
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2012-11-22 14:20:52 PST ---
(This is derived from Issue 8996 )


import std.typecons;
Tuple!T foo(T)(T x) {
    return tuple(x);
}
void main() {
    import std.bigint;
    foo(BigInt(1));
}


DMD 2.061alpha gives:

...\dmd2\src\phobos\std\internal\math\biguintcore.d(92): Error: non-constant
expression ZERO

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9057


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice
            Summary|Non-constant expression     |Regression(Beta): Segfault
                   |error in biguintcore        |or "Non-constant
                   |                            |expression" error with
                   |                            |local import


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2012-11-28 00:42:42 PST ---
Reduced test case shows it is related to the local import.
Looks as though semantic isn't being run on the array literal.
In the first case, it segfaults because the array literal type is still NULL.
------------------ 
struct Bug9057(T)
{
    T x;
}

void test9507() {
    import thug;
    Bug9057!(BugInt) xxx;
}
------------------ thug.d, case 1. Segfault
struct BugInt
{
    uint[] data = [0];
}
------------------ thug.d, case 2: "Non-constant expression ZEROX"
struct BugInt
{
    uint[] data = ZEROX;
}
enum uint [] ZEROX = [0];

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 10, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9057



--- Comment #2 from github-bugzilla@puremagic.com 2012-12-10 03:56:00 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/af2c21b58e357a214da2bc1cf959c322f8ad1cd4
fix issue 9057 - Regression(Beta): Segfault or 'Non-constant expression' error
with local import

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 10, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9057


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


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