www.digitalmars.com         C & C++   DMDScript  

D - error

reply "Carlos" <carlos8294 msn.com> writes:
Any posibility that I'm getting this?

Assertion failure: 'ie' on line 253 in file 'declaration.c'

abnormal program termination

My objective is to create 2 functions: MMult (to multiply matrixes) and MInv
(to invert a matrix), and they're already implemented but when I attempt to
try them with 2x2 matrixes, I get that message.

-------------------------
Carlos 8294
http://carlos3.netfirms.com/
May 24 2002
next sibling parent "Pavel Minayev" <evilone omen.ru> writes:
"Carlos" <carlos8294 msn.com> wrote in message
news:aclrb6$o6c$1 digitaldaemon.com...

 Assertion failure: 'ie' on line 253 in file 'declaration.c'

 abnormal program termination
This happens sometimes. Try commenting out different blocks of code till you find the line which causes the error. Then you might want to report this to Walter. BTW, I suggest you first check for things like structures declared on stack and initialized, and also static arrays on stack - it caused the compiler to crash sometimes in older releases...
May 24 2002
prev sibling next sibling parent reply "Walter" <walter digitalmars.com> writes:
"Carlos" <carlos8294 msn.com> wrote in message
news:aclrb6$o6c$1 digitaldaemon.com...
 Any posibility that I'm getting this?

 Assertion failure: 'ie' on line 253 in file 'declaration.c'

 abnormal program termination
Any such is a compiler bug. Please post/email me a reproducible example so I can fix it. Thanks, -Walter
May 24 2002
parent reply "Carlos" <carlos8294 msn.com> writes:
I could fix it. But the solution leads me to give you a suggestion: though
you claim (in all your right) that resizing arrays is easy, resizing
multidimensional arrays is really hard. I had to do this:

int size=2; //or any value
double a[][];
a.length=size;
for (int i=0;i<a.length;i++)
    a[i].length=size;

Too complicated. I can't think about an easy way to do it, but probably you
should.
Besides, there's no way to do this:

void foo(double [][]a) { ... }

double [2][2] a;
foo(a);

The compiler says there's no compatibility. I hope it's a bug because if
it's not, then you should do something about it.
The compiler also says that it can't be done:
double a;
a=abs(a);
Because there's no difference between abs ( extended ) and abs ( int ).
Isn't it ridiculous?

"Walter" <walter digitalmars.com> escribió en el mensaje
news:acm3cj$vbc$1 digitaldaemon.com...
 "Carlos" <carlos8294 msn.com> wrote in message
 news:aclrb6$o6c$1 digitaldaemon.com...
 Any posibility that I'm getting this?

 Assertion failure: 'ie' on line 253 in file 'declaration.c'

 abnormal program termination
Any such is a compiler bug. Please post/email me a reproducible example so
I
 can fix it. Thanks, -Walter
May 24 2002
next sibling parent "Carlos" <carlos8294 msn.com> writes:
"Carlos" <carlos8294 msn.com> escribió en el mensaje
news:acmglh$1cbb$1 digitaldaemon.com...
 I could fix it. But the solution leads me to give you a suggestion: though
 you claim (in all your right) that resizing arrays is easy, resizing
 multidimensional arrays is really hard. I had to do this:

 int size=2; //or any value
 double a[][];
 a.length=size;
 for (int i=0;i<a.length;i++)
     a[i].length=size;

 Too complicated. I can't think about an easy way to do it, but probably
you
 should.
It leads to something: resizing three-dimensional, four-dimensional, etc. arrays becomes painful.
May 24 2002
prev sibling next sibling parent reply "Pavel Minayev" <evilone omen.ru> writes:
"Carlos" <carlos8294 msn.com> wrote in message
news:acmglh$1cbb$1 digitaldaemon.com...

 The compiler also says that it can't be done:
 double a;
 a=abs(a);
 Because there's no difference between abs ( extended ) and abs ( int ).
 Isn't it ridiculous?
It's an old story. Since it has to convert double anyhow (either to int or to extended), it treats both in the same way. And yes, it seems weird to me. However, Walter does not want to make the overloading rules more comlicated, so the only solution currently is to perform a cast if you use Phobos, and if you write your own library and want it to work properly, you have to overload the function for ALL types.
May 24 2002
next sibling parent reply "Carlos" <carlos8294 msn.com> writes:
I understand that, but what about a swap function? It also has to be
overloaded for ALL types and the parameters have to be out or inout, but
then it has to cast float or double and the compiler says (because it also
happened to me) that cast(extended) { something I don't remember well } is
not a lvalue. Probably you (or Walter) should reconsider your ideas about
the program.

"Pavel Minayev" <evilone omen.ru> escribió en el mensaje
news:acn1t5$1qfv$1 digitaldaemon.com...
 "Carlos" <carlos8294 msn.com> wrote in message
 news:acmglh$1cbb$1 digitaldaemon.com...

 The compiler also says that it can't be done:
 double a;
 a=abs(a);
 Because there's no difference between abs ( extended ) and abs ( int ).
 Isn't it ridiculous?
It's an old story. Since it has to convert double anyhow (either to int or to extended), it treats both in the same way. And yes, it seems weird to me. However, Walter does not want to make the overloading rules more comlicated, so the only solution currently is to perform a cast if you use Phobos, and if you write your own library and want it to work properly, you have to overload the function for ALL types.
May 24 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"Carlos" <carlos8294 msn.com> wrote in message
news:acn27k$1qmc$1 digitaldaemon.com...

 I understand that, but what about a swap function? It also has to be
 overloaded for ALL types and the parameters have to be out or inout, but
 then it has to cast float or double and the compiler says (because it also
 happened to me) that cast(extended) { something I don't remember well } is
 not a lvalue. Probably you (or Walter) should reconsider your ideas about
 the program.
This is okay. Since function actually takes _pointer_ to argument, it needs to know the size of the value being pointed to. And if you would be able to cast float to extended, it would get 4 bytes where it expects to see 10... So, for swap(), the ONLY way to write it properly is to overload it for all types, or to make it template if language supports this...
May 25 2002
parent reply "Carlos" <carlos8294 msn.com> writes:
"Pavel Minayev" <evilone omen.ru> escribió en el mensaje
news:acngg7$27os$1 digitaldaemon.com...
 "Carlos" <carlos8294 msn.com> wrote in message
 news:acn27k$1qmc$1 digitaldaemon.com...

 I understand that, but what about a swap function? It also has to be
 overloaded for ALL types and the parameters have to be out or inout, but
 then it has to cast float or double and the compiler says (because it
also
 happened to me) that cast(extended) { something I don't remember well }
is
 not a lvalue. Probably you (or Walter) should reconsider your ideas
about
 the program.
This is okay. Since function actually takes _pointer_ to argument, it needs to know the size of the value being pointed to. And if you would be able to cast float to extended, it would get 4 bytes where it expects to see 10... So, for swap(), the ONLY way to write it properly is to overload it for all types, or to make it template if language supports this...
Yes, but if I explicitely write (to try): char a,b; swap ( (char) a, (char) b ); (swap is a function that I wrote) it works.
May 25 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"Carlos" <carlos8294 msn.com> wrote in message
news:acp9cj$2602$1 digitaldaemon.com...

 Yes, but if I explicitely write (to try):

 char a,b;
 swap ( (char) a, (char) b );

 (swap is a function that I wrote) it works.
And how does your swap() look?
May 26 2002
parent reply "Carlos" <carlos8294 msn.com> writes:
"Pavel Minayev" <evilone omen.ru> escribió en el mensaje
news:acq2sn$2u4n$1 digitaldaemon.com...
 "Carlos" <carlos8294 msn.com> wrote in message
 news:acp9cj$2602$1 digitaldaemon.com...

 Yes, but if I explicitely write (to try):

 char a,b;
 swap ( (char) a, (char) b );

 (swap is a function that I wrote) it works.
And how does your swap() look?
It can't be simpler: void swap ( char a, char b) { char z=a; a=b; b=z; } and for int and extended it's exactly the same.
May 26 2002
parent "Pavel Minayev" <evilone omen.ru> writes:
"Carlos" <carlos8294 msn.com> wrote in message
news:acrm97$17s8$1 digitaldaemon.com...

 char a,b;
 swap ( (char) a, (char) b );
It can't be simpler: void swap ( char a, char b) { char z=a; a=b; b=z; } and for int and extended it's exactly the same.
Since you've defined it for chars, it'll work for chars. There is nothing wrong in casting a char to char - it still continues to be an lvalue.
May 27 2002
prev sibling parent "Carlos" <carlos8294 msn.com> writes:
I understand that, but what about a swap function? It also has to be
overloaded for ALL types and the parameters have to be out or inout, but
then it has to cast float or double and the compiler says (because it also
happened to me) that cast(extended) { something I don't remember well } is
not a lvalue. Probably you (or Walter) should reconsider your ideas about
the language.

"Pavel Minayev" <evilone omen.ru> escribió en el mensaje
news:acn1t5$1qfv$1 digitaldaemon.com...
 "Carlos" <carlos8294 msn.com> wrote in message
 news:acmglh$1cbb$1 digitaldaemon.com...

 The compiler also says that it can't be done:
 double a;
 a=abs(a);
 Because there's no difference between abs ( extended ) and abs ( int ).
 Isn't it ridiculous?
It's an old story. Since it has to convert double anyhow (either to int or to extended), it treats both in the same way. And yes, it seems weird to me. However, Walter does not want to make the overloading rules more comlicated, so the only solution currently is to perform a cast if you use Phobos, and if you write your own library and want it to work properly, you have to overload the function for ALL types.
May 24 2002
prev sibling next sibling parent reply "Walter" <walter digitalmars.com> writes:
"Carlos" <carlos8294 msn.com> wrote in message
news:acmglh$1cbb$1 digitaldaemon.com...
 I could fix it. But the solution leads me to give you a suggestion: though
 you claim (in all your right) that resizing arrays is easy, resizing
 multidimensional arrays is really hard. I had to do this:

 int size=2; //or any value
 double a[][];
 a.length=size;
 for (int i=0;i<a.length;i++)
     a[i].length=size;

 Too complicated. I can't think about an easy way to do it, but probably
you
 should.
You're right, but I'm going to defer that for the moment.
 Besides, there's no way to do this:

 void foo(double [][]a) { ... }

 double [2][2] a;
 foo(a);

 The compiler says there's no compatibility. I hope it's a bug because if
 it's not, then you should do something about it.
I'm afraid that D is stuck with that - the problem is that rectangular static arrays are laid out differently in memory than rectangular dynamic arrays. There's no easy conversion like there is for one dimensional arrays.
 The compiler also says that it can't be done:
 double a;
 a=abs(a);
 Because there's no difference between abs ( extended ) and abs ( int ).
 Isn't it ridiculous?
D follows the rule that a match must be unambiguous. I wish to avoid the mess C++ has gotten into with its layers of confusing rules about which is a "better" match. Trying to even understand the rule (so I could implement it) for template "better" matches about caused my brain to explode. D is not going to go down that merry path, no matter how sweet the poppies smell at first <g>.
May 24 2002
parent "Carlos" <carlos8294 msn.com> writes:
"Walter" <walter digitalmars.com> escribió en el mensaje
news:acn93k$2028$1 digitaldaemon.com...
 The compiler also says that it can't be done:
 double a;
 a=abs(a);
 Because there's no difference between abs ( extended ) and abs ( int ).
 Isn't it ridiculous?
D follows the rule that a match must be unambiguous. I wish to avoid the mess C++ has gotten into with its layers of confusing rules about which is
a
 "better" match. Trying to even understand the rule (so I could implement
it)
 for template "better" matches about caused my brain to explode. D is not
 going to go down that merry path, no matter how sweet the poppies smell at
 first <g>.
Yes, but I don't think it's ambiguous to do that, because double should automatically go with extended not with int, because double isn't like an int.
May 25 2002
prev sibling parent "OddesE" <OddesE_XYZ hotmail.com> writes:
"Carlos" <carlos8294 msn.com> wrote in message
news:acmglh$1cbb$1 digitaldaemon.com...
 I could fix it. But the solution leads me to give you a suggestion: though
 you claim (in all your right) that resizing arrays is easy, resizing
 multidimensional arrays is really hard. I had to do this:

 int size=2; //or any value
 double a[][];
 a.length=size;
 for (int i=0;i<a.length;i++)
     a[i].length=size;

 Too complicated. I can't think about an easy way to do it, but probably
you
 should.
 Besides, there's no way to do this:

 void foo(double [][]a) { ... }

 double [2][2] a;
 foo(a);

 The compiler says there's no compatibility. I hope it's a bug because if
 it's not, then you should do something about it.
 The compiler also says that it can't be done:
 double a;
 a=abs(a);
 Because there's no difference between abs ( extended ) and abs ( int ).
 Isn't it ridiculous?
I think this was discussed before. double and extended are two seperate types, so if only abs(int) and abs(extended) are defined the compiler does not know which one to use... You need to define abs(double): double abs (in double dValue) { return (cast (double) abs (cast (extended) dValue)); } I typed this in Outlook, so I hope I got the syntax right... -- Stijn OddesE_XYZ hotmail.com http://OddesE.cjb.net _________________________________________________ Remove _XYZ from my address when replying by mail
May 26 2002
prev sibling parent reply "Carlos" <carlos8294 msn.com> writes:
Due to the same program, this has come to me: how does D compare floating
point numbers: C-like (floatingPoint1==floatingPoint2 is always false) or
differently (sometimes floatingPoint1==floatingPoint2 is true)? For example,

double a=1;
double b=1;
if (a==b) ... ;

It should be true.
May 24 2002
parent reply "Walter" <walter digitalmars.com> writes:
"Carlos" <carlos8294 msn.com> wrote in message
news:acmid0$1dtp$1 digitaldaemon.com...
 Due to the same program, this has come to me: how does D compare floating
 point numbers: C-like (floatingPoint1==floatingPoint2 is always false) or
 differently (sometimes floatingPoint1==floatingPoint2 is true)? For
example,
 double a=1;
 double b=1;
 if (a==b) ... ;

 It should be true.
You're right, it should be true. Is it not in D?
May 24 2002
parent reply "Sean L. Palmer" <seanpalmer earthlink.net> writes:
I think he's bringing up the point about floating point numbers that they
teach you in school, that comparisons for equality of floats can fail even
though the numbers are exceedingly similar.   1.0 != 1.0000000000000001

I'd love to have a "is approximately equal to" operator in D.  The
double-squiggly thing in math.  ~  I don't think FP hardware usually has
such an operation though, but it essentially boils down to this:

bool approx_equal(float a,float b)
{
  static const float epsilon = 1e-12f;  // or whatever
  return fabs(b-a)<epsilon;
}

or if you want to get fancy,  this is probably a better test (works for a
wider range of values, but slower):

bool approx_equal(float a,float b)
{
  static const float epsilon = 1e-12f;  // or whatever
  return fabs(b-a) <= max(fabs(a),fabs(b))*epsilon;
}

Deciding on a good epsilon is the difficult part.  Different applications
will need different epsilons, which is probably why nobody has standardized
this yet.

Sean

"Walter" <walter digitalmars.com> wrote in message
news:acn8p8$1vri$1 digitaldaemon.com...
 "Carlos" <carlos8294 msn.com> wrote in message
 news:acmid0$1dtp$1 digitaldaemon.com...
 Due to the same program, this has come to me: how does D compare
floating
 point numbers: C-like (floatingPoint1==floatingPoint2 is always false)
or
 differently (sometimes floatingPoint1==floatingPoint2 is true)? For
example,
 double a=1;
 double b=1;
 if (a==b) ... ;

 It should be true.
You're right, it should be true. Is it not in D?
May 25 2002
parent "Walter" <walter digitalmars.com> writes:
"Sean L. Palmer" <seanpalmer earthlink.net> wrote in message
news:acne4m$25k1$1 digitaldaemon.com...
 Deciding on a good epsilon is the difficult part.  Different applications
 will need different epsilons, which is probably why nobody has
standardized
 this yet.
Epsilon is the wrong approach. The best way would be to have a function that rounds each number to a specified number of bits of precision, and then compare for equality.
May 25 2002