www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Class comparison problems

reply Niboshi <Niboshi_member pathlink.com> writes:
First of all, I'm not an English speaker. So be tolerant of my poor English.

I'm using Win32 compiler v0.135.
I wrote the following code and had some problems:

int main()
{
Object c = new Object;
Object d = null;
if (null == c) {}  // Access Violation
if (c == null) {}  // Ok
if (d == c) {}     // Access Violation
if (c == d) {}     // Ok

bit b;
b = (1 == 2);      // Ok
b = (c == d);      // Compile Error(cannot convert int to bit)

return 0;
}

I'm sorry if these are known issues...
Oct 10 2005
parent reply BCS <BCS_member pathlink.com> writes:
In article <dieq96$187c$1 digitaldaemon.com>, Niboshi says...
First of all, I'm not an English speaker. So be tolerant of my poor English.

I'm using Win32 compiler v0.135.
I wrote the following code and had some problems:

int main()
{
Object c = new Object;
Object d = null;
if (null == c) {}  // Access Violation
if (c == null) {}  // Ok
if (d == c) {}     // Access Violation
if (c == d) {}     // Ok
All of these should use the "is" operator.
bit b;
b = (1 == 2);      // Ok
b = (c == d);      // Compile Error(cannot convert int to bit)

return 0;
}

I'm sorry if these are known issues...
Your English is better than some of the postings from English speakers (my self included).
Oct 10 2005
parent Niboshi <Niboshi_member pathlink.com> writes:
In article <dif1c1$5cm$1 digitaldaemon.com>, BCS says...
In article <dieq96$187c$1 digitaldaemon.com>, Niboshi says...
First of all, I'm not an English speaker. So be tolerant of my poor English.

I'm using Win32 compiler v0.135.
I wrote the following code and had some problems:

int main()
{
Object c = new Object;
Object d = null;
if (null == c) {}  // Access Violation
if (c == null) {}  // Ok
if (d == c) {}     // Access Violation
if (c == d) {}     // Ok
All of these should use the "is" operator.
bit b;
b = (1 == 2);      // Ok
b = (c == d);      // Compile Error(cannot convert int to bit)

return 0;
}

I'm sorry if these are known issues...
Your English is better than some of the postings from English speakers (my self included).
Thanks a lot! I should have read documentation more carefully before posting :)
Oct 11 2005