www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 981] New: CFTE fails in non-template and functions that takes no args.

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

           Summary: CFTE fails in non-template and functions that takes no
                    args.
           Product: D
           Version: 1.006
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: kevinbealer gmail.com


In the following code, I think A, B, C, and D should work, but only A works. 
If B, C, or D is uncommented, an error is reported during compilation.  I'm not
sure if this is one or more bugs, but at the moment the CFTE stuff seems to
require the called function to take parameters and also to be called from a
template.  (I'm guessing this has to do with constant folding working
differently in different contexts.)

Kevin

//---------------

char[] one(char[] hi)
{
    return "abc "~hi;
}

char[] two()
{
    return "xyz";
}

struct A(T) {
    const char[] z = one("x");
}

/+

//dmd: interpret.c:96: Expression*
//FuncDeclaration::interpret(Expressions*): Assertion `parameters &&
//parameters->dim == dim' failed.

struct B(T) {
    const char[] z = two();
}
+/

/+
// t1.d(28): Error: cannot evaluate (one)("x") at compile time
struct C {
    const char[] z = one("x");
}
+/

/+
//t1.d(25): Error: cannot evaluate (two)() at compile time

struct D {
    const char[] z = two();
}
+/

int main()
{
    A!(int) a;
    //B!(int) b;
    //C c;
    //D d;

    return 0;
}


-- 
Feb 18 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=981


technocrat7 gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed in DMD 1.007


-- 
Feb 22 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=981






Added to DStress as
http://destress.kuehne.cn/run/b/bug_interpret_96_A.d
http://destress.kuehne.cn/run/b/bug_interpret_96_B.d
http://destress.kuehne.cn/run/b/bug_interpret_96_C.d
http://destress.kuehne.cn/run/b/bug_interpret_96_D.d
http://destress.kuehne.cn/run/b/bug_interpret_96_E.d


-- 
Feb 26 2007