dword

Beta Testing discussion on mikroPascal PRO for PIC32.
Post Reply
Author
Message
jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

dword

#1 Post by jpc » 14 May 2011 10:33

it looks like the compiler refuses to accept dword value as binary with the msb set :

Code: Select all

test := %11111111111111111111111111111111; // results in Argument is out of range "-1" to "dword"
test := $ffffffff;  // is accepted 
after checking this error seems to be present in the PIC and dsPIC compilers as well.
Au royaume des aveugles, les borgnes sont rois.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: dword

#2 Post by filip » 18 May 2011 11:55

Hi,

It should report error also for the second line, as it is an unsigned type.
I have reported this to our developers, it should be fixed as soon as possible.

I apologize for the inconvenience.

Regards,
Filip.

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

Re: dword

#3 Post by jpc » 18 May 2011 12:02

i think it should NOT report any error, it is unsigned as you say which should allow all bits , anyway i do not see why a signed type would not be allowed to be set by binary literal to negative value
Au royaume des aveugles, les borgnes sont rois.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: dword

#4 Post by janni » 18 May 2011 12:29

Obviously, performing range checking on binary or hex coded integral numbers is a mistake as every value expressed in this way makes sense, whatever the type of variable (signed or unsigned) they're being assigned to. As long as the size in bits or bytes is correct, there should never be any further check, or one gets strange and unfounded errors, like
jpc wrote:

Code: Select all

dword_var := %11111111111111111111111111111111; //Argument is out of range "-1" to "dword"
or

Code: Select all

short_var := %10000000; // Argument is out of range "128" to "short"
short_var := $80;       // Argument is out of range "128" to "short"
where apparently constants are first interpreted according to some arbitrary type (signed in first example, unsigned in second) and only then compared to actual type of a variable.

Post Reply

Return to “mikroPascal PRO for PIC32 Beta Testing”