www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15542] New: pure function with no argument returning

https://issues.dlang.org/show_bug.cgi?id=15542

          Issue ID: 15542
           Summary: pure function with no argument returning different
                    values (with void-initialized static array)
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: timothee.cour2 gmail.com

void main(){
  auto a1=test4;
  int[6]temp;
  auto a2=test4;
  assert(a1==a2);// passes but...
  writeln(test4);
  writeln(test4);
}

pure
int test4(){
  int[4]a=void;
  return a[0]+a[1]+a[2]+a[3];
}

// prints different valuse:
-1907472476
-1907439709

DMD64 D Compiler v2.069-devel-6b2b521

which brings the question:
should "pure" disallow void-initialized stack allocated data?

--
Jan 10