mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 20:19:25 +02:00
fix range check error when array size > maxlongint
This commit is contained in:
parent
b151676e8a
commit
fac96dd2ed
@ -39,8 +39,10 @@ interface
|
||||
|
||||
{# Returns the minimal value between @var(a) and @var(b) }
|
||||
function min(a,b : longint) : longint;{$ifdef USEINLINE}inline;{$endif}
|
||||
function min(a,b : int64) : int64;{$ifdef USEINLINE}inline;{$endif}
|
||||
{# Returns the maximum value between @var(a) and @var(b) }
|
||||
function max(a,b : longint) : longint;{$ifdef USEINLINE}inline;{$endif}
|
||||
function max(a,b : int64) : int64;{$ifdef USEINLINE}inline;{$endif}
|
||||
{# Returns the value in @var(x) swapped to different endian }
|
||||
Function SwapInt64(x : int64): int64;{$ifdef USEINLINE}inline;{$endif}
|
||||
{# Returns the value in @var(x) swapped to different endian }
|
||||
@ -152,6 +154,18 @@ uses
|
||||
end;
|
||||
|
||||
|
||||
function min(a,b : int64) : int64;{$ifdef USEINLINE}inline;{$endif}
|
||||
{
|
||||
return the minimal of a and b
|
||||
}
|
||||
begin
|
||||
if a>b then
|
||||
min:=b
|
||||
else
|
||||
min:=a;
|
||||
end;
|
||||
|
||||
|
||||
function max(a,b : longint) : longint;{$ifdef USEINLINE}inline;{$endif}
|
||||
{
|
||||
return the maximum of a and b
|
||||
@ -164,6 +178,18 @@ uses
|
||||
end;
|
||||
|
||||
|
||||
function max(a,b : int64) : int64;{$ifdef USEINLINE}inline;{$endif}
|
||||
{
|
||||
return the maximum of a and b
|
||||
}
|
||||
begin
|
||||
if a<b then
|
||||
max:=b
|
||||
else
|
||||
max:=a;
|
||||
end;
|
||||
|
||||
|
||||
Function SwapLong(x : longint): longint;{$ifdef USEINLINE}inline;{$endif}
|
||||
var
|
||||
y : word;
|
||||
@ -1162,7 +1188,10 @@ initialization
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.38 2004-03-29 19:19:35 florian
|
||||
Revision 1.39 2004-05-22 23:33:18 peter
|
||||
fix range check error when array size > maxlongint
|
||||
|
||||
Revision 1.38 2004/03/29 19:19:35 florian
|
||||
+ arm floating point register saving implemented
|
||||
* hopefully stabs generation for MacOSX fixed
|
||||
+ some defines for arm added
|
||||
|
@ -3004,9 +3004,9 @@ implementation
|
||||
write_rtti_name;
|
||||
{ size of elements }
|
||||
rttiList.concat(Tai_const.Create_32bit(elesize));
|
||||
{ count of elements }
|
||||
{ count of elements, prevent overflow for 0..maxlongint }
|
||||
if not(IsDynamicArray) then
|
||||
rttiList.concat(Tai_const.Create_32bit(highrange-lowrange+1));
|
||||
rttiList.concat(Tai_const.Create_32bit(min(int64(highrange)-lowrange+1,maxlongint)));
|
||||
{ element type }
|
||||
rttiList.concat(Tai_const_symbol.Create(tstoreddef(elementtype.def).get_rtti_label(rt)));
|
||||
{ variant type }
|
||||
@ -6184,7 +6184,10 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.236 2004-05-01 22:05:01 florian
|
||||
Revision 1.237 2004-05-22 23:33:18 peter
|
||||
fix range check error when array size > maxlongint
|
||||
|
||||
Revision 1.236 2004/05/01 22:05:01 florian
|
||||
+ added lib support for Amiga/MorphOS syscalls
|
||||
|
||||
Revision 1.235 2004/04/29 19:56:37 daniel
|
||||
|
Loading…
Reference in New Issue
Block a user