Skip to content

Detect that a function pointer parameter has not the right size #305

Open
@zedalaye

Description

@zedalaye

Prerequisites

  • This rule has not already been suggested.
  • This should be a new rule, not an improvement to an existing rule.
  • This rule would be generally useful, not specific to my code or setup.

Suggested rule title

Pointers parameters should have the right size

Rule description

Check that pointer parameters have the right size according to the compiler architecture.

Rationale

In a migration process from Win32 to Win64, I encountered this error :

  n := tmpp.Count;
  p := nil;
  DynArraySetLength(p, field_type, 1, @n);

The code was build for Win32, so n was an Integer
Now DynArraySetLength takes a PNativeInt which is 64bits wide under Win64 and the Delphi compiler does not emit a single warning about this critical issue.

Would be awesome if Sonarqube could help finding those problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or requestruleImprovements or additions to rules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions