View Issue Details

IDProjectCategoryView StatusLast Update
0035533FPCCompilerpublic2019-05-10 21:03
ReporterCraig Chapman Assigned ToSven Barth  
Status resolvedResolutionfixed 
Product Version3.3.1 
Fixed 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}

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

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

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

  P: pointer;

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


Thaddy de Koning

2019-05-07 13:27

reporter   ~0116065

Last edited: 2019-05-07 13: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 13:33

reporter   ~0116066

Last edited: 2019-05-07 13:34

View 2 revisions

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

Sven Barth

2019-05-10 21:03

manager   ~0116123

Last edited: 2019-05-10 21: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. needs to be psomerec^.foo).

Issue History

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