diff --git a/.gitattributes b/.gitattributes index c0f363627b..ed11ebde65 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13239,6 +13239,7 @@ tests/webtbs/tw2382.pp svneol=native#text/plain tests/webtbs/tw2388.pp svneol=native#text/plain tests/webtbs/tw23962.pp svneol=native#text/plain tests/webtbs/tw2397.pp svneol=native#text/plain +tests/webtbs/tw24007.pp svneol=native#text/plain tests/webtbs/tw2409.pp svneol=native#text/plain tests/webtbs/tw2421.pp svneol=native#text/plain tests/webtbs/tw2423.pp svneol=native#text/plain diff --git a/compiler/nutils.pas b/compiler/nutils.pas index d8d2757d90..48cbc69f49 100644 --- a/compiler/nutils.pas +++ b/compiler/nutils.pas @@ -1029,7 +1029,8 @@ implementation { only orddefs and enumdefs are actually bitpacked. Don't consider e.g. an access to a 3-byte record as "bitpacked", since it isn't } - (tvecnode(n).left.resultdef.typ in [orddef,enumdef]) and + (tvecnode(n).left.resultdef.typ = arraydef) and + (tarraydef(tvecnode(n).left.resultdef).elementdef.typ in [orddef,enumdef]) and not(tarraydef(tvecnode(n).left.resultdef).elepackedbitsize in [8,16,32,64]); subscriptn: result:= diff --git a/tests/webtbs/tw24007.pp b/tests/webtbs/tw24007.pp new file mode 100644 index 0000000000..82c39babd1 --- /dev/null +++ b/tests/webtbs/tw24007.pp @@ -0,0 +1,21 @@ +var + str: bitpacked array [1..6] of 'a'..'z'; + i: integer; + ch: char; + error: boolean; +begin + error := false; + for i := 1 to 6 do str[i] := chr(ord('a')+i-1); + + for i := 1 to 6 do begin + write('str[i] = ''', str[i], '''; ord(str[2]) = ',ord(str[i])); + ch:=str[i]; {if we had used directly str[i] in the expression below, the correct value would have been read} + if ch <> chr(ord(str[i])) then + begin + write(' ==> Bug: chr(',ord(ch),') read, excpected chr(',ord('a')+i-1,')'); + error:=true; + end; + writeln; + end; + halt(ord(error)); +end.