www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14823] New: pure function returns uninitialized value


          Issue ID: 14823
           Summary: pure function returns uninitialized value
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: jeff thefirst.org

To reproduce, enter and run the following code:

import std.stdio;
pure int getUninitializedValue()
  int[1] array = void; // array is uninitialized
  return array[0];
void main(string[] args)

Expected result: Compiler error for a pure function with uninitialized memory.

Actual result: It prints 185734 (or another uninitialized value from the

Suggested solution: Don't allow accessing uninitialized memory inside a pure

Jul 24 2015