Integer constant declaration using typecasting generates range error at usage
Original Reporter info from Mantis: denis.totoliciu
-
Reporter name: Totoliciu Denis Dan
Original Reporter info from Mantis: denis.totoliciu
- Reporter name: Totoliciu Denis Dan
Description:
Trying to use "CValueErr" constant anywhere in the program will generate the following error:
BugTest.lpr(13,11) Error: range check error while evaluating constants (0 must be between 10 and 20)
The compiler will not generate any error if:
* the line where "CValueErr" is used is commented and
* the declaration of the constant if left as it is, without deleting it or commenting it.
This way of declaring and using the constant "CValueErr" is compilable with Delphi.
Steps to reproduce:
type
TInterval = 10..20;
const
CValueErr = TInterval(0);
CValueGood: TInterval = TInterval(0);
begin
WriteLn(CValueErr); // generate range checking error
WriteLn(CValueGood); // OK
end.
Mantis conversion info:
- Mantis ID: 37847
- Version: 3.2.0
- Monitored by: » denis.totoliciu (Totoliciu Denis Dan)