mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-05-30 18:42:34 +02:00
* fix #39447: when checking whether the parameters are valid for pointer arithmetic check the *correct* parameter for being valid pointer-like type (I'd say that this was a copy&paste mistake...)
+ added test
This commit is contained in:
parent
a20e8b9a3d
commit
c994b5efe8
@ -3068,9 +3068,9 @@ implementation
|
||||
if (rt=niln) then
|
||||
CGMessage3(type_e_operator_not_supported_for_types,node2opstr(nodetype),ld.typename,'NIL');
|
||||
if (not(cs_extsyntax in current_settings.moduleswitches) and not(nf_internal in flags)) or
|
||||
(not (is_pchar(ld) or is_chararray(ld) or is_open_chararray(ld) or is_widechar(ld) or is_widechararray(ld) or is_open_widechararray(ld)) and
|
||||
(not (is_pchar(rd) or is_chararray(rd) or is_open_chararray(rd) or is_widechar(rd) or is_widechararray(rd) or is_open_widechararray(rd)) and
|
||||
not(cs_pointermath in current_settings.localswitches) and
|
||||
not((ld.typ=pointerdef) and tpointerdef(ld).has_pointer_math)) then
|
||||
not((rd.typ=pointerdef) and tpointerdef(rd).has_pointer_math)) then
|
||||
CGMessage3(type_e_operator_not_supported_for_types,node2opstr(nodetype),ld.typename,rd.typename);
|
||||
if (rd.typ=pointerdef) and
|
||||
(tpointerdef(rd).pointeddef.size>1) then
|
||||
|
30
tests/webtbs/tw39447.pp
Normal file
30
tests/webtbs/tw39447.pp
Normal file
@ -0,0 +1,30 @@
|
||||
unit tw39447;
|
||||
{$IFDEF FPC}
|
||||
{$MODE Delphi}
|
||||
{$ENDIF}
|
||||
|
||||
interface
|
||||
uses sysutils;
|
||||
|
||||
function ptr_twist() : boolean;
|
||||
|
||||
implementation
|
||||
|
||||
function ptr_twist() : boolean;
|
||||
var
|
||||
x : pchar;
|
||||
x2 : pchar;
|
||||
const
|
||||
str : ShortString = '123456789';
|
||||
begin
|
||||
|
||||
x := @(str[2]);
|
||||
x := x + 5;
|
||||
x2:= 5 + x; // FPC fails here
|
||||
|
||||
result := (x = x2);
|
||||
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user