June 28, 2015 Does the compiler check for safe? | ||||
---|---|---|---|---|
| ||||
I took some code that was annotated safe, and modified it to use a buffer internal to the class, and an offset counter. Some of the routines adjusted the counter. I forgot to remove the "safe" annotation. It compiled without error. So... 1) The compiler didn't check for safety 2) It counts as safe if you only modify local-to-the-class variables (and I misunderstood). or 3) This error is only detected on execution But which? (I'm still writing the code, so I can't yet try to execute it, and I took off the safe annotation because after I read the definition in TDPL it seemed a mistaken annotation. But perhaps I misunderstand.) |
June 28, 2015 Re: Does the compiler check for safe? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charles Hixson | On Sunday, 28 June 2015 at 07:49:41 UTC, Charles Hixson wrote: > I took some code that was annotated safe, and modified it to use a buffer internal to the class, and an offset counter. Some of the routines adjusted the counter. I forgot to remove the "safe" annotation. > > It compiled without error. So... > 1) The compiler didn't check for safety > 2) It counts as safe if you only modify local-to-the-class variables (and I misunderstood). > or > 3) This error is only detected on execution > > But which? > > (I'm still writing the code, so I can't yet try to execute it, and I took off the safe annotation because after I read the definition in TDPL it seemed a mistaken annotation. But perhaps I misunderstand.) Please don't post in Announce for questions, Learn would be a better place. For your problem, reading the list http://dlang.org/function.html#safe-functions I'm not sure what is unsafe in what you do. |
Copyright © 1999-2021 by the D Language Foundation