[Issue 6438] New: [CTFE] wrong error "value used before set" when	slicing =void array
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Fri Aug  5 03:00:14 PDT 2011
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=6438
           Summary: [CTFE] wrong error "value used before set" when
                    slicing =void array
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: dmitry.olsh at gmail.com
--- Comment #0 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2011-08-05 03:00:04 PDT ---
void fillWithZero(T)(T[] arr)
{
    foreach(ref x; arr)
        x = 0;
}
T[4] f(T)()
{
    T[4] stackSpace = void;
    fillWithZero(stackSpace[]);
    return stackSpace;
}
static assert(f!int() == [0,0,0,0]); 
Fails with:
bug6XXX.d(11): Error: variable stackSpace is used before initialization
bug6XXX.d(11): Error: cannot evaluate fillWithZero(stackSpace[]) at compile
time
bug6XXX.d(16): Error: cannot evaluate f() at compile time
bug6XXX.d(16): Error: static assert  (cast(int[])f() == [0,0,0,0]) is not
evaluatable at compile time
It's CTFE only issue and is a blocker for one overload of phobos insertInPlace.
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
    
    
More information about the Digitalmars-d-bugs
mailing list