稍微展示一下d的@live的神奇.

@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); // `p`有未定义状态,不能读它.

    return p; //同上,返回的`p`未定义.
 }
posted @ 2022-01-17 13:20  zjh6  阅读(19)  评论(0)    收藏  举报  来源