Jump to content
  • Advertisement
Sign in to follow this  
Sir Ementaler

Warning "Value is too large for data type" incorrect

This topic is 815 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Using AngelScript version 2.31.1, the following behaviors were observed regarding the "Value is too large for data type" warning:

 

The warning treats int8 and int16 as if they were unsigned and produces a warning iff the assigned value is respectively outside of the ranges 0-255 and 0-65535. The following snippet produces two warnings:

int8 x = -1;
int16 y = -1;

The following snippet erroneously doesn't:

int8 x = 255;
int16 y = 65535;

When a 32-bit variable overflow occurs during assigning a value to an int8 or int16 variable, the warning may be erroneously omitted. The following snippet doesn't produce a warning:

int8 x = 4294967297;
int16 y = 4294967297;

The warning is never displayed for types int32, int64, and uint64 no matter the assigned value. The following snippet doesn't produce a warning:

int x = 4294967295;
int64 y = 18446744073709551616;
uint64 z = 18446744073709551616;
For the remaining unsigned integer types, the warning may be erroneously omitted if a 64-bit variable overflow occurs. The following snippet doesn't produce a warning:
uint8 x = 18446744073709551616;
uint16 y = 18446744073709551616;
uint z = 18446744073709551616;

I would be thankful if these issues could be fixed, especially the first one, where warnings are produced incorrectly. Some of our API functions have default arguments such as int8 arg = -1, which cause users' logs to be flooded with warnings whenever they make intensive use of them.

Edited by Sir Ementaler

Share this post


Link to post
Share on other sites
Advertisement

I've fixed the other warnings in revision 2351.

 

I decided to make the compiler emit an error if the parsed constant is bigger than max uint64, i.e. bigger than 18446744073709551615, as numbers this big cannot be represented by any native type anyway.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!