FPC does not do range checks on boolean arrays consisting of one element.
Original Reporter info from Mantis: 440bx @440bx
-
Reporter name:
Original Reporter info from Mantis: 440bx @440bx
- Reporter name:
Description:
if an array consisting of one boolean element is indexed outside the one element, the compiler does not emit a warning nor error. See sample program, the compiler should emit a warning or an error. Note: the presence or absence of $R+ does not affect the compilation in any way in this case.
{$APPTYPE CONSOLE}
{$R+}
program BooleanRangeChecks;
type
TARRAY_BOOLEAN_TYPE = array[true..true] of integer;
TARRAY_INTEGER_TYPE = array[1 .. 5] of integer;
var
BooleanArray : TARRAY_BOOLEAN_TYPE;
IntegerArray : TARRAY_INTEGER_TYPE;
IntegerVariable : integer;
begin
IntegerVariable := 1;
{ no warning about index being out of range }
{ or use "false" instead of an expression }
BooleanArray[1 > 2] := IntegerVariable;
writeln(BooleanArray[low(BooleanArray)]);
end.
Steps to reproduce:
compile the sample program
Mantis conversion info:
- Mantis ID: 37112
- OS: Windows
- OS Build: likely all
- Platform: probably independent
- Version: 3.0.4