Advertisement

Warning "Value is too large for data type" incorrect

Started by September 12, 2016 06:32 PM
1 comment, last by WitchLord 8 years, 2 months ago

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.

I'll look into this.

The first one was already fixed two days ago in revision 2350, but I'll verify if the others persist.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement