www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Does the compiler check for safe?

reply Charles Hixson via Digitalmars-d-announce writes:
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.)
Jun 28 2015
parent "cym13" <cpicard openmailbox.org> writes:
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.
Jun 28 2015