www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - safe functions

reply Sean Eskapp <eatingstaples gmail.com> writes:
This is either a compiler bug, or outdated language documentation, but I'm
having some freedom with  safe functions:

    * No casting from a pointer type to any type other than void*.
    * No modification of pointer values.
    * No taking the address of a local variable or function parameter.

I've attached code which does all three of these things, which compiles and
runs.

Inline assembler was an error, as well as casting from integer to a pointer
type, but I didn't test anything else.

I'm using dmd2.exe as my compiler.
begin 644 main.d




M("\O('=R:71I;F< =7-I;F< ;6%L9F]R;65D('!O:6YT97(-" D-" EY(#T 
M)G [("\O('1A:VEN9R!A9&1R97-S(&]F('!A<F%M971E<BP 04Y$(&-H86YG



G(&UA:6XH*0T*>PT*"6EN="!X(#T
`
end
Jan 05 2011
next sibling parent "Simen kjaeraas" <simen.kjaras gmail.com> writes:
Sean Eskapp <eatingstaples gmail.com> wrote:

 This is either a compiler bug, or outdated language documentation, but  
 I'm
 having some freedom with  safe functions:

     * No casting from a pointer type to any type other than void*.
     * No modification of pointer values.
     * No taking the address of a local variable or function parameter.

 I've attached code which does all three of these things, which compiles  
 and runs.

 Inline assembler was an error, as well as casting from integer to a  
 pointer
 type, but I didn't test anything else.

 I'm using dmd2.exe as my compiler.
Safe-D is currently not implemented, at least in whole. Other issues also have higher priority. Also, this group is for automated messages from BugZilla. Please either post these things as bugs[1] or in the digitalmars.D.learn of digitalmars.D newsgroups. [1]: http://d.puremagic.com/issues/enter_bug.cgi -- Simen
Jan 05 2011
prev sibling parent "Lars T. Kyllingstad" <public kyllingen.NOSPAMnet> writes:
On Wed, 05 Jan 2011 15:35:09 +0000, Sean Eskapp wrote:

 This is either a compiler bug, or outdated language documentation, but
 I'm having some freedom with  safe functions:
 
     * No casting from a pointer type to any type other than void*. * No
     modification of pointer values.
     * No taking the address of a local variable or function parameter.
 
 I've attached code which does all three of these things, which compiles
 and runs.
 
 Inline assembler was an error, as well as casting from integer to a
 pointer type, but I didn't test anything else.
 
 I'm using dmd2.exe as my compiler.
 import std.stdio;
 
  safe void foo(int x)
 {
 	int a;
 	int* y = &a; // taking address of local variable char* z =
 	cast(char*)y; // casting pointer to non-pointer type *z = 4; // 
writing
 	using malformed pointer
 	
 	y = &x; // taking address of parameter, AND changing pointer 
value *y =
 	4; // changing value
 	
 	int b = cast(int)y; // casting from pointer type to type that 
isn't
 	void*
 }
 
 void main()
 {
 	int x = 50;
 	foo(x);
 }
Hi! This forum is just a feed from Bugzilla, it is not meant for discussions. Please file a bug report at http://d.puremagic.com/issues/ instead. Thanks, Lars
Jan 05 2011