Finding unsafe line of code

codephantom me at noyb.com
Fri Dec 29 10:23:24 UTC 2017


On Friday, 29 December 2017 at 09:38:50 UTC, Vino wrote:
>
>   Let me re-frame the question with an example, as the Dsafe 
> the below line of code is considered as unsafe(Pointer 
> arithmetic), so let imagine that we have several similar line 
> of code, how do we find such unsafe line, does the compiler 
> check these unsafe code and complain while compiling a .d 
> program or do we need to pass any compiler arguments to perform 
> these check while compiling the code or do we need to manually 
> perform an analysis of each line of code and correct the same 
> in case if we find any unsafe code.
>
>
> ini[10] a;
> int* p = &a[0];
> for (size_t i=0; i <= 10; i++)
> p[i] = ...;
>
> From,
> Vino.B

Is this what you're looking for?

https://dlang.org/spec/function.html#safe-functions

Just annotate your functions with @safe (as @system is the 
default).


More information about the Digitalmars-d-learn mailing list