Compiler warning "argument may be out of range [val]

Post your requests and ideas on the future development of mikroC PRO for ARM.
Post Reply
Author
Message
Lionel83
Posts: 100
Joined: 11 Dec 2016 18:31

Compiler warning "argument may be out of range [val]

#1 Post by Lionel83 » 15 Feb 2017 17:32

Hi,

I have this test code :

Code: Select all

typedef enum {ONE, TWO, TREE} test_enum;

test_enum test_value(int i)
{
  test_enum val = TREE;
  
  if (i==1) val = ONE;
  else if (i==2) val = TWO;
  else val = TREE;
  
  return val;
}
Why I have this message "argument may be out of range" :?:
It is impossible that 'val' was out of range :!:

Regards,
Lionel

User avatar
dusan.poluga
mikroElektronika team
Posts: 780
Joined: 02 Feb 2017 14:21

Re: Compiler warning "argument may be out of range [val]

#2 Post by dusan.poluga » 20 Feb 2017 16:50

Hi,

Please send me your project. Because your code does not give me an error.
Tell me where in the code your error appears. Send me a screenshot if you can.

Regards,
Dusan Poluga.

Lionel83
Posts: 100
Joined: 11 Dec 2016 18:31

Re: Compiler warning "argument may be out of range [val]

#3 Post by Lionel83 » 20 Feb 2017 17:35

Hi,

Yes, very easy to replicate.
You have the screenshot in the zip.
You can see the warning line 11.

Regards,
Lionel
Attachments
Test_Enum.zip
(264.58 KiB) Downloaded 794 times

User avatar
dusan.poluga
mikroElektronika team
Posts: 780
Joined: 02 Feb 2017 14:21

Re: Compiler warning "argument may be out of range [val]

#4 Post by dusan.poluga » 20 Feb 2017 18:01

Hi,

Please reinstall the compiler.
Your code compiles without errors.

Regards,
Dusan Poluga.

Lionel83
Posts: 100
Joined: 11 Dec 2016 18:31

Re: Compiler warning "argument may be out of range [val]

#5 Post by Lionel83 » 21 Feb 2017 17:12

Hi

Why re-install the compiler (version is 4.9.1) ?
He work fine, just this warning who is not logical.
Did you checked the box "Hints" in the log message window ? If the box is not checked, you can not see the message.

Regards,
Lionel

User avatar
dusan.poluga
mikroElektronika team
Posts: 780
Joined: 02 Feb 2017 14:21

Re: Compiler warning "argument may be out of range [val]

#6 Post by dusan.poluga » 21 Feb 2017 18:04

Hi,

I wanted to say update.
But from what i see you have the updated version.

Regards,
Dusan Poluga.

Lionel83
Posts: 100
Joined: 11 Dec 2016 18:31

Re: Compiler warning "argument may be out of range [val]

#7 Post by Lionel83 » 27 Feb 2017 15:25

Hi,

And so, what is the solution ?

Regards,
Lionel

User avatar
dusan.poluga
mikroElektronika team
Posts: 780
Joined: 02 Feb 2017 14:21

Re: Compiler warning "argument may be out of range [val]

#8 Post by dusan.poluga » 27 Feb 2017 15:59

Hi,

Just create a new empty project and paste the code in it.
It should compile without errors.

Regards,
Dusan Poluga.

Lionel83
Posts: 100
Joined: 11 Dec 2016 18:31

Re: Compiler warning "argument may be out of range [val]

#9 Post by Lionel83 » 27 Feb 2017 17:26

dusan.poluga wrote: Just create a new empty project and paste the code in it.
It should compile without errors.
:?
Ok, I do that and the warning is always here. See project join in attachment and screenshot.
Note that I make this code only to illustrate the problem. I have the save problem in others projects with other enum record.

Regards,
Lionel
Attachments
Screenshot.png
Screenshot.png (41.54 KiB) Viewed 12558 times
Test-Enum2.zip
(963 Bytes) Downloaded 192 times

User avatar
dusan.poluga
mikroElektronika team
Posts: 780
Joined: 02 Feb 2017 14:21

Re: Compiler warning "argument may be out of range [val]

#10 Post by dusan.poluga » 27 Feb 2017 17:44

Hi,

Here is the code of the compilation on my computer.
It does not give me any warnings.

Regards,
Attachments
enum.PNG
enum.PNG (14.74 KiB) Viewed 12550 times
Dusan Poluga.

Lionel83
Posts: 100
Joined: 11 Dec 2016 18:31

Re: Compiler warning "argument may be out of range [val]

#11 Post by Lionel83 » 01 Mar 2017 15:04

Hi,

I just install the version 5.0 and the problem disappear :D

Regards,
Lionel

Post Reply

Return to “mikroC PRO for ARM Wish List”