mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-24 22:10:42 +02:00
* disable overflow checking when performing pointer arithmetic
(mantis 8049) git-svn-id: trunk@5822 -
This commit is contained in:
parent
85289e80ce
commit
d0b6292137
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -7944,6 +7944,7 @@ tests/webtbs/tw7975.pp svneol=native#text/plain
|
|||||||
tests/webtbs/tw7975a.pp svneol=native#text/plain
|
tests/webtbs/tw7975a.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw8018.pp svneol=native#text/plain
|
tests/webtbs/tw8018.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw8028.pp svneol=native#text/plain
|
tests/webtbs/tw8028.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw8049.pp svneol=native#text/plain
|
||||||
tests/webtbs/ub1873.pp svneol=native#text/plain
|
tests/webtbs/ub1873.pp svneol=native#text/plain
|
||||||
tests/webtbs/ub1883.pp svneol=native#text/plain
|
tests/webtbs/ub1883.pp svneol=native#text/plain
|
||||||
tests/webtbs/uw0555.pp svneol=native#text/plain
|
tests/webtbs/uw0555.pp svneol=native#text/plain
|
||||||
|
@ -498,6 +498,11 @@ interface
|
|||||||
internalerror(2002072705);
|
internalerror(2002072705);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
checkoverflow:=
|
||||||
|
checkoverflow and
|
||||||
|
(left.resultdef.typ<>pointerdef) and
|
||||||
|
(right.resultdef.typ<>pointerdef);
|
||||||
|
|
||||||
{$ifdef cpu64bit}
|
{$ifdef cpu64bit}
|
||||||
case nodetype of
|
case nodetype of
|
||||||
xorn,orn,andn,addn:
|
xorn,orn,andn,addn:
|
||||||
@ -684,6 +689,11 @@ interface
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
checkoverflow:=
|
||||||
|
checkoverflow and
|
||||||
|
(left.resultdef.typ<>pointerdef) and
|
||||||
|
(right.resultdef.typ<>pointerdef);
|
||||||
|
|
||||||
if nodetype<>subn then
|
if nodetype<>subn then
|
||||||
begin
|
begin
|
||||||
if (right.location.loc<>LOC_CONSTANT) then
|
if (right.location.loc<>LOC_CONSTANT) then
|
||||||
|
@ -744,9 +744,9 @@ interface
|
|||||||
tmpreg : tregister;
|
tmpreg : tregister;
|
||||||
hl : tasmlabel;
|
hl : tasmlabel;
|
||||||
cmpop : boolean;
|
cmpop : boolean;
|
||||||
|
|
||||||
{ true, if unsigned types are compared }
|
{ true, if unsigned types are compared }
|
||||||
unsigned : boolean;
|
unsigned : boolean;
|
||||||
|
checkoverflow : boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{ to make it more readable, string and set (not smallset!) have their
|
{ to make it more readable, string and set (not smallset!) have their
|
||||||
@ -819,15 +819,18 @@ interface
|
|||||||
else
|
else
|
||||||
location_reset(location,LOC_FLAGS,OS_NO);
|
location_reset(location,LOC_FLAGS,OS_NO);
|
||||||
|
|
||||||
load_left_right(cmpop, (cs_check_overflow in current_settings.localswitches) and
|
checkoverflow:=
|
||||||
(nodetype in [addn,subn,muln]));
|
(nodetype in [addn,subn,muln]) and
|
||||||
|
(cs_check_overflow in current_settings.localswitches) and
|
||||||
|
(left.resultdef.typ<>pointerdef) and
|
||||||
|
(right.resultdef.typ<>pointerdef);
|
||||||
|
|
||||||
|
load_left_right(cmpop, checkoverflow);
|
||||||
|
|
||||||
if not(cmpop) then
|
if not(cmpop) then
|
||||||
location.register := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
|
location.register := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
|
||||||
|
|
||||||
if not(cs_check_overflow in current_settings.localswitches) or
|
if not(checkoverflow) then
|
||||||
(cmpop) or
|
|
||||||
(nodetype in [orn,andn,xorn]) then
|
|
||||||
begin
|
begin
|
||||||
case nodetype of
|
case nodetype of
|
||||||
addn, muln, xorn, orn, andn:
|
addn, muln, xorn, orn, andn:
|
||||||
|
@ -146,6 +146,7 @@ var
|
|||||||
tmpreg: tregister;
|
tmpreg: tregister;
|
||||||
hl: tasmlabel;
|
hl: tasmlabel;
|
||||||
cmpop: boolean;
|
cmpop: boolean;
|
||||||
|
checkoverflow: boolean;
|
||||||
|
|
||||||
{ true, if unsigned types are compared }
|
{ true, if unsigned types are compared }
|
||||||
unsigned: boolean;
|
unsigned: boolean;
|
||||||
@ -214,14 +215,18 @@ begin
|
|||||||
else
|
else
|
||||||
location_reset(location, LOC_FLAGS, OS_NO);
|
location_reset(location, LOC_FLAGS, OS_NO);
|
||||||
|
|
||||||
load_left_right(cmpop, (cs_check_overflow in current_settings.localswitches) and
|
checkoverflow:=
|
||||||
(nodetype in [addn, subn, muln]));
|
(nodetype in [addn,subn,muln]) and
|
||||||
|
(cs_check_overflow in current_settings.localswitches) and
|
||||||
|
(left.resultdef.typ<>pointerdef) and
|
||||||
|
(right.resultdef.typ<>pointerdef);
|
||||||
|
|
||||||
|
load_left_right(cmpop, checkoverflow);
|
||||||
|
|
||||||
if not (cmpop) then
|
if not (cmpop) then
|
||||||
location.register := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
|
location.register := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
|
||||||
|
|
||||||
if not (cs_check_overflow in current_settings.localswitches) or (cmpop) or
|
if not (checkoverflow) then begin
|
||||||
(nodetype in [orn, andn, xorn]) then begin
|
|
||||||
case nodetype of
|
case nodetype of
|
||||||
addn, muln, xorn, orn, andn:
|
addn, muln, xorn, orn, andn:
|
||||||
begin
|
begin
|
||||||
|
15
tests/webtbs/tw8049.pp
Normal file
15
tests/webtbs/tw8049.pp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
program bug;
|
||||||
|
|
||||||
|
{$Q+}
|
||||||
|
|
||||||
|
const s:array[0..31] of char='Hell* world';
|
||||||
|
index:longint=-6;
|
||||||
|
|
||||||
|
var c:char;
|
||||||
|
p,q:Pchar;
|
||||||
|
|
||||||
|
begin
|
||||||
|
p:=s;
|
||||||
|
q:=p-index;
|
||||||
|
writeln('Hello ',q);
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user