Thread overview
[Bug] e2ir: cannot cast from bit to byte
Jan 23, 2004
Manfred Nowak
Jan 23, 2004
J Anderson
Jan 24, 2004
J C Calvarese
Jan 24, 2004
Manfred Nowak
January 23, 2004
<code>
void main()
{
  bit bi;
  byte by;

  by=bi;
}
</code>

This is generated in the coding phase.

So long.
-- 
Fight Spam! Join EuroCAUCE: http://www.euro.cauce.org/ 2EA56D6D4DC41ABA311615946D3248A1
January 23, 2004
Manfred Nowak wrote:

><code>
>void main()
>{
>  bit bi;
>  byte by;
>
>  by=bi;
>}
></code>
>
>This is generated in the coding phase.
>
>So long.
>  
>
This is by-design.  I would like the possibility to convert an array of bits to an array of bytes but the above code probably doesn't make much sense.

BTW:
You can always go:

 by=(bi)?1:0;

-- 
-Anderson: http://badmama.com.au/~anderson/
January 24, 2004
J Anderson wrote:
> Manfred Nowak wrote:
> 
>> <code>
>> void main()
>> {
>>  bit bi;
>>  byte by;
>>
>>  by=bi;
>> }
>> </code>
>>
>> This is generated in the coding phase.
>>
>> So long.
>>  
>>
> This is by-design.  I would like the possibility to convert an array of bits to an array of bytes but the above code probably doesn't make much sense.
> 
> BTW:
> You can always go:
> 
>  by=(bi)?1:0;
> 

This probably a dumb question, but does anyone know what does e2ir mean?

Since the error message includes a line number and a description, I can't complain, but I am curious what "e2ir" means.


-- 
Justin
http://jcc_7.tripod.com/d/
January 24, 2004
J Anderson wrote:

> This is by-design.
[...]

Where to find that in the docs?

I only found:
| Usual Arithmetic Conversions
[...]
| 5. Else the integer promotions are done on each operand, followed by:
|    1. If both are the same type, no more conversions are done.
|    2. If both are signed or both are unsigned, the smaller type is
|       converted to the larger.
|    3. If the signed type is larger than the unsigned type, the
|       unsigned type is converted to the signed type.


Consequently dmd is able to convert bit to anything else than byte. The
following code compiles(!):
<code>
void main(){
  bit bi=true;

  ubyte r0=bi;
  short r1=bi;
  ushort r2=bi;
  int r3=bi;
  uint r4=bi;
  long r5=bi;
  ulong r6=bi;
  float r7=bi;
  double r8=bi;
  real r9=bi;

  char r10=bi;
  dchar r11=bi;
  wchar r12=bi;
}
</code>

[...]
| the above code probably doesn't make much sense.

It is stripped off code, as required by walter. :-)


So long.
-- 
Fight Spam! Join EuroCAUCE: http://www.euro.cauce.org/ 2EA56D6D4DC41ABA311615946D3248A1