www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Internal error: ..\ztc\cgcs.c 213

reply Alex Stevenson <ans104 cs.york.ac.uk> writes:
The following function crashes DMD 0.143 on WinXP SP2:

bit[] bit_union( bit[] alpha, bit[] beta )
in
{
	assert( alpha.length == beta.length );
	assert( alpha !is null );
	assert( beta !is null );
}
body
{
	bit[] output = alpha.dup;
	
	foreach( int pos, bit val; beta )
		output[pos] |= val;    // <-- X
		
	return output;
}

replacing the line marked X with an empty body or:
output[pos] = cast(bit) (val | output[pos]);

Seems to fix it. Though for some reason I need that cast or I get

yhc\regcodefrag.d(288): cannot implicitly convert expression 
(cast(int)(val) | cast(int)((output)[(pos)])) of type int to bit

A quick google shows that the same internal error occured in this post:
http://www.digitalmars.com/d/archives/digitalmars/D/25575.html - seems 
to be a similar problem, {|,^}= to a bit array member.

Can't find an entry in the change log for it being fixed though, so I 
guess this could well be a duplicate.
Jan 14 2006
parent "Walter Bright" <newshound digitalmars.com> writes:
"Alex Stevenson" <ans104 cs.york.ac.uk> wrote in message 
news:dqb7bs$179$1 digitaldaemon.com...
 Can't find an entry in the change log for it being fixed though, so I 
 guess this could well be a duplicate.
It's a known problem, the op= operators fail for bit operations.
Jan 15 2006