View Issue Details

IDProjectCategoryView StatusLast Update
0035533FPCCompilerpublic2019-05-10 23:03
ReporterCraig ChapmanAssigned ToSven Barth 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformamd64OSWindowsOS Version10
Product Version3.3.1Product Buildr41976 
Target VersionFixed in Version3.3.1 
Summary0035533: Type helper for pointer compiles but cannot be used due to Error: Illegal Qualifier
DescriptionPlease see source code which fails to compile under Steps To Reproduce.
Errors occur on lines 25&26: Error: Illegal Qualifier
Steps To Reproduceprogram Project1;
{$mode delphiunicode}

type
  TPointerHelper = record helper for pointer
    function AsNativeUint: nativeuint;
    function PCharLen: uint32;
  end;

function TPointerHelper.AsNativeUint: nativeuint;
begin
  Result := nativeuint(self);
end;

function TPointerHelper.PCharLen: uint32;
begin
  Result := 5; //- Just here to illustrate the issue.
end;

var
  P: pointer;

begin
  P := @ParamStr(0); //- Just a nonsense pointer.
  Writeln( P.AsNativeUInt );
  Writeln( P.PCharLen );
  Readln;
end.
Additional InformationNote: Mode set to 'DelphiUnicode' - This source compiles using Delphi compiler.
TagsNo tags attached.
Fixed in Revision42036
FPCOldBugId
FPCTarget-
Attached Files

Activities

Thaddy de Koning

2019-05-07 15:27

reporter   ~0116065

Last edited: 2019-05-07 15:31

View 2 revisions

Pointers are untyped.... This should not compile at all... but it does...
(You should not be able to write a type helper for something that has no type. Delphi disallows its equivalent record helper)

Thaddy de Koning

2019-05-07 15:33

reporter   ~0116066

Last edited: 2019-05-07 15:34

View 2 revisions

You can work around this using a NativeUint/PtrUint helper and use casts.

Sven Barth

2019-05-10 23:03

manager   ~0116123

Last edited: 2019-05-10 23:03

View 2 revisions

Please test and close if okay.

As a workaround you can add {$modeswitch autoderef-} after setting the mode, though you won't be able to access members on a pointer to a record without dereferencing the pointer then (e.g. psomerec.foo needs to be psomerec^.foo).

Issue History

Date Modified Username Field Change
2019-05-07 09:28 Craig Chapman New Issue
2019-05-07 15:27 Thaddy de Koning Note Added: 0116065
2019-05-07 15:31 Thaddy de Koning Note Edited: 0116065 View Revisions
2019-05-07 15:33 Thaddy de Koning Note Added: 0116066
2019-05-07 15:34 Thaddy de Koning Note Edited: 0116066 View Revisions
2019-05-10 23:03 Sven Barth Assigned To => Sven Barth
2019-05-10 23:03 Sven Barth Status new => resolved
2019-05-10 23:03 Sven Barth Resolution open => fixed
2019-05-10 23:03 Sven Barth Fixed in Version => 3.3.1
2019-05-10 23:03 Sven Barth Fixed in Revision => 42036
2019-05-10 23:03 Sven Barth FPCTarget => -
2019-05-10 23:03 Sven Barth Note Added: 0116123
2019-05-10 23:03 Sven Barth Note Edited: 0116123 View Revisions