diff options
author | florian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-01-28 20:56:15 +0000 |
---|---|---|
committer | florian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2021-01-28 20:56:15 +0000 |
commit | 697cb23408905c7b69261f14301c18d7adcf70dc (patch) | |
tree | c42df497c29bbabe7900aacf3445b1c02efd73e0 /compiler | |
parent | 0841c39d3b5f7e3b3feaff5afde955191c8599cf (diff) | |
download | fpc-697cb23408905c7b69261f14301c18d7adcf70dc.tar.gz |
* fix type conversion for array indicies if the ordinal ranges of the involved types do not overlap, resolves #38413
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@48449 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/nmem.pas | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/nmem.pas b/compiler/nmem.pas index c5920e5741..2f2851f249 100644 --- a/compiler/nmem.pas +++ b/compiler/nmem.pas @@ -1051,7 +1051,16 @@ implementation and not is_64bit(right.resultdef) {$endif not cpu64bitaddr} then - newordtyp:=Torddef(right.resultdef).ordtype + begin + { in case of an integer type, we need a new type which covers declaration range and index range, + see tests/webtbs/tw38413.pp + } + if is_integer(right.resultdef) then + newordtyp:=range_to_basetype(min(TConstExprInt(Tarraydef(left.resultdef).lowrange),torddef(right.resultdef).low), + max(TConstExprInt(Tarraydef(left.resultdef).highrange),torddef(right.resultdef).high)) + else + newordtyp:=Torddef(right.resultdef).ordtype; + end else newordtyp:=torddef(sizesinttype).ordtype; inserttypeconv(right,corddef.create(newordtyp, |