mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-15 15:19:25 +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/tw8018.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/ub1883.pp svneol=native#text/plain
|
||||
tests/webtbs/uw0555.pp svneol=native#text/plain
|
||||
|
@ -498,6 +498,11 @@ interface
|
||||
internalerror(2002072705);
|
||||
end;
|
||||
|
||||
checkoverflow:=
|
||||
checkoverflow and
|
||||
(left.resultdef.typ<>pointerdef) and
|
||||
(right.resultdef.typ<>pointerdef);
|
||||
|
||||
{$ifdef cpu64bit}
|
||||
case nodetype of
|
||||
xorn,orn,andn,addn:
|
||||
@ -684,6 +689,11 @@ interface
|
||||
end;
|
||||
end;
|
||||
|
||||
checkoverflow:=
|
||||
checkoverflow and
|
||||
(left.resultdef.typ<>pointerdef) and
|
||||
(right.resultdef.typ<>pointerdef);
|
||||
|
||||
if nodetype<>subn then
|
||||
begin
|
||||
if (right.location.loc<>LOC_CONSTANT) then
|
||||
|
@ -744,9 +744,9 @@ interface
|
||||
tmpreg : tregister;
|
||||
hl : tasmlabel;
|
||||
cmpop : boolean;
|
||||
|
||||
{ true, if unsigned types are compared }
|
||||
unsigned : boolean;
|
||||
checkoverflow : boolean;
|
||||
|
||||
begin
|
||||
{ to make it more readable, string and set (not smallset!) have their
|
||||
@ -819,15 +819,18 @@ interface
|
||||
else
|
||||
location_reset(location,LOC_FLAGS,OS_NO);
|
||||
|
||||
load_left_right(cmpop, (cs_check_overflow in current_settings.localswitches) and
|
||||
(nodetype in [addn,subn,muln]));
|
||||
checkoverflow:=
|
||||
(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
|
||||
location.register := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
|
||||
|
||||
if not(cs_check_overflow in current_settings.localswitches) or
|
||||
(cmpop) or
|
||||
(nodetype in [orn,andn,xorn]) then
|
||||
if not(checkoverflow) then
|
||||
begin
|
||||
case nodetype of
|
||||
addn, muln, xorn, orn, andn:
|
||||
|
@ -146,6 +146,7 @@ var
|
||||
tmpreg: tregister;
|
||||
hl: tasmlabel;
|
||||
cmpop: boolean;
|
||||
checkoverflow: boolean;
|
||||
|
||||
{ true, if unsigned types are compared }
|
||||
unsigned: boolean;
|
||||
@ -214,14 +215,18 @@ begin
|
||||
else
|
||||
location_reset(location, LOC_FLAGS, OS_NO);
|
||||
|
||||
load_left_right(cmpop, (cs_check_overflow in current_settings.localswitches) and
|
||||
(nodetype in [addn, subn, muln]));
|
||||
checkoverflow:=
|
||||
(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
|
||||
location.register := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
|
||||
|
||||
if not (cs_check_overflow in current_settings.localswitches) or (cmpop) or
|
||||
(nodetype in [orn, andn, xorn]) then begin
|
||||
if not (checkoverflow) then begin
|
||||
case nodetype of
|
||||
addn, muln, xorn, orn, andn:
|
||||
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