Forums

casting/Code gen bug ?

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

casting/Code gen bug ?

Postby hopscc » Mon Jul 07, 2008 1:58 am

Is this a casting or code gen bug?
Code: Select all
   def main is shared
      b  = 255u8
      b = 255u8 & 31u8         #OK
      assert b == 31_u8
      assert b.getType is Byte

      b1 = 255u8
      b1 &= 31u8   #0x1f_u8     # OK
      assert b1 == 31u8
      
      b1 = 255u8
      b1 = b1 & 31u8   # compile error: cannot implicitly convert int to byte (c#)
      print b1
      assert b1 == 31u8
      
      b1 = 255u8
      b2 = 31u8 #0x1fu8 
      b1 = b2 & b1 # compile error: cannot implicitly convert int to byte (c#)
      print b
      assert b1 == 31u8



Lines marked with 'compile error comment emit a compile error from the c# compiler phase. The earlier lines doing the same thing ( marked #OK) compiles OK.
using int32 ( defaults - no u?? on literals) compiles fine.
if I cast the # compile error lines
Code: Select all
 b1 = (b1 & 31u8) to uint8

get a warning from cobra but compiles and runs fine.
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: casting/Code gen bug ?

Postby Charles » Tue Jul 08, 2008 12:28 am

I'll have to look into this later.

I'll probably be off Cobra Tue and back on Wed, FYI.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: casting/Code gen bug ?

Postby Charles » Mon Aug 18, 2008 5:41 am

I consider this a bug in the code generation. Fixed and checked in.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 20 guests

cron