Thread overview | |||||
---|---|---|---|---|---|
|
May 27, 2019 compiler does not detect accessing on null class object. | ||||
---|---|---|---|---|
| ||||
hello, code below: ----- class a { string a1; } a a1; writeln(a1.a1); ----- compiles and produce "core dump" or "segfault", does this fit the original D design? why the compiler does not detect for accessing a null object and refused to compile? And, 2nd question: where can I find the Subset spec of SafeD? Thanks! -------------- binghoo dang |
May 27, 2019 Re: compiler does not detect accessing on null class object. | ||||
---|---|---|---|---|
| ||||
Posted in reply to dangbinghoo | On Monday, 27 May 2019 at 15:13:00 UTC, dangbinghoo wrote: > hello, > > code below: > ----- > class a { > string a1; > } > > a a1; > writeln(a1.a1); > ----- > > compiles and produce "core dump" or "segfault", does this fit the original D design? why the compiler does not detect for accessing a null object and refused to compile? > > > > And, 2nd question: where can I find the Subset spec of SafeD? > > > Thanks! > > -------------- > binghoo dang 1.) Yes this is by design. It is not easy to detect this at compile time. It does not break safety 2.) https://dlang.org/spec/function.html#function-safety https://dlang.org/spec/memory-safe-d.html https://dlang.org/articles/safed.html#safed-subset |
May 28, 2019 Re: compiler does not detect accessing on null class object. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Kozak | On Monday, 27 May 2019 at 15:29:32 UTC, Daniel Kozak wrote:
> On Monday, 27 May 2019 at 15:13:00 UTC, dangbinghoo wrote:
>> hello,
>>
>
>
> 1.)
> Yes this is by design. It is not easy to detect this at compile time.
> It does not break safety
>
> 2.)
> https://dlang.org/spec/function.html#function-safety
> https://dlang.org/spec/memory-safe-d.html
> https://dlang.org/articles/safed.html#safed-subset
thanks a lot.
so, The SafeD Subset consists of [function-safety, memory-safety].
|
Copyright © 1999-2021 by the D Language Foundation