www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - dmd 101: crash

reply Regan Heath <regan netwin.co.nz> writes:
class A {
   const int b;
   this()
   {
     b = 2;
   }
}

void main()
{
   A a = new A();
   a.b = 5; //remove this line, no crash
}

D:\D\src\temp>dmd const.d
const.d(5): b is not an lvalue
<crash>

Regan

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Sep 12 2004
parent reply Tyro <ridimz_at yahoo.dot.com> writes:
Regan Heath wrote:

 class A {
   const int b;
   this()
   {
     b = 2;
   }
 }
 
 void main()
 {
   A a = new A();
   a.b = 5; //remove this line, no crash
 }
 
 D:\D\src\temp>dmd const.d
 const.d(5): b is not an lvalue
 <crash>
 
 Regan
 

It's value must be know upon first encounter). And once known, such value cannot be overridden. Andrew
Sep 12 2004
parent reply Regan Heath <regan netwin.co.nz> writes:
On Sun, 12 Sep 2004 21:37:56 -0400, Tyro <ridimz_at yahoo.dot.com> wrote:
 Regan Heath wrote:

 class A {
   const int b;
   this()
   {
     b = 2;
   }
 }

 void main()
 {
   A a = new A();
   a.b = 5; //remove this line, no crash
 }

 D:\D\src\temp>dmd const.d
 const.d(5): b is not an lvalue
 <crash>

 Regan

It's value must be know upon first encounter). And once known, such value cannot be overridden.

Yes, the error is correct, line 5 is "b = 2;" in the ctor for the class. However, the compiler crashes when it sees the "a.b = 5;" line, that is the bug. Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Sep 12 2004
parent Tyro <ridimz_at yahoo.dot.com> writes:
 Yes, the error is correct, line 5 is "b = 2;" in the ctor for the class. 
 However, the compiler crashes when it sees the "a.b = 5;" line, that is 
 the bug.
 
 Regan
 

I C. Thanks for clarifying! Andrew
Sep 12 2004