www.digitalmars.com         C & C++   DMDScript  

D - bug ( |= )

reply "Carlos Santander B." <carlos8294 msn.com> writes:
This:

bit b;
...
b|=(x==y);

produces this:

Internal error: ..\ztc\glopp.c 1619

But if I change it to:

b=b|(x==y);

it says 'cannot implicitly convert int to bit', so I had to do this:

b=cast(bit)(b|(x==y));

I think it's kind of weird. Just in case, I prefer to use bits for booleans.

-------------------------
Carlos Santander


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.449 / Virus Database: 251 - Release Date: 2003-01-27
Feb 05 2003
parent reply Burton Radons <loth users.sourceforge.net> writes:
Carlos Santander B. wrote:
 This:
 
 bit b;
 ...
 b|=(x==y);
 
 produces this:
 
 Internal error: ..\ztc\glopp.c 1619

It shouldn't produce an error, but it's invalid code: "bit" is not an integer type.
 But if I change it to:
 
 b=b|(x==y);

Use "b=b||(x==y);".
Feb 05 2003
parent reply "Mike Wynn" <mike.wynn l8night.co.uk> writes:
There is a difference between

b|c and b||c

b|c should always be eval'ed.
( a|b|c) (should not produce jumps)
( a || b || c ) should !

"Burton Radons" <loth users.sourceforge.net> wrote in message
news:b1squn$131j$1 digitaldaemon.com...
 Carlos Santander B. wrote:
 This:

 bit b;
 ...
 b|=(x==y);

 produces this:

 Internal error: ..\ztc\glopp.c 1619

It shouldn't produce an error, but it's invalid code: "bit" is not an integer type.
 But if I change it to:

 b=b|(x==y);

Use "b=b||(x==y);".

Feb 06 2003
parent Burton Radons <loth users.sourceforge.net> writes:
Mike Wynn wrote:
 There is a difference between
 
 b|c and b||c
 
 b|c should always be eval'ed.
 ( a|b|c) (should not produce jumps)
 ( a || b || c ) should !

C 101 time eh. || is also a sequence point, so "a ++ || a ++" has a defined result. But it has nothing to do with Carlos' code.
Feb 06 2003