D mentioned on Rust discussions site

Walter Bright newshound2 at digitalmars.com
Fri May 22 02:04:19 UTC 2020


On 5/21/2020 2:26 PM, Joseph Rushton Wakeling wrote:
> (Tried with a freshly built dmd 2.092.0.)

Because it's a bug I fixed fairly recently. Not sure if it's been pulled yet. 
Anyhow, my version of dmd produces:

   @live int* test1()
   {
     import core.stdc.stdlib : free, malloc;
     import core.stdc.stdio;

     scope p = cast(int*) malloc(int.sizeof);

     free(p);

     printf("%d\n",*p); // variable `p` has undefined state and cannot be read

     return p; // variable `p` has undefined state and cannot be read
               // variable `p` is returned but is Undefined
  }

The error messages aren't the greatest, but they are accurate.


More information about the Digitalmars-d mailing list