Re: @safe functions

2011-01-05 Thread Lars T. Kyllingstad
On Wed, 05 Jan 2011 15:35:09 +, 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


Re: Missing trailing } still compiles under DMD1.057

2010-04-12 Thread Lars T. Kyllingstad

Please report bugs here:

  http://d.puremagic.com/issues/

This newsgroup is just a feed from Bugzilla.

-Lars



Sam Hu wrote:

Given below code:

module uniword;

import std.c.stdio;
import std.c.windows.windows;

import std.stdio;
import *;

void main()
{

testFoo;

}
struct Foo
{
int a;
static Foo opCall(int a)
{
Foo s;
s.a=a;
return s;
}
}

void testFoo()
{
Foo x=Foo(10);
writefln(%d\n,x.a);

readln;



Re: ieeeFlags do not work properly

2010-01-07 Thread Lars T. Kyllingstad

Torben Hagerup wrote:

Run under D version 2.037, the program below runs through without raising any 
assert exceptions. This shows an erratic behavior with respect to ieeeFlags 
that is hardly intended. Other ieeeFlags also work (or, rather, do not work) in 
unexpected ways.



import std.math;

void main() {
// The execution leads to no assert errors
 real a,b=3.5;
 resetIeeeFlags();
 assert(!ieeeFlags.divByZero); // so far no zero division
 a=3.5/0.0L; // but now ...
 assert(a==real.infinity); // yes, exactly
 assert(!ieeeFlags.divByZero); // perhaps not, after all
 b/=0.0L; // once more, the same, really
 assert(b==real.infinity); // yes, the same
 assert(ieeeFlags.divByZero); // oops, not the same after all?
}


Hi!

Please report bugs in Bugzilla:

  http://d.puremagic.com/issues/index.cgi

This newsgroup is just a feed from Bugzilla.

-Lars