integrated-application-development / integrated-application-development/sonar-delphi

Detect that a function pointer parameter has not the right size

Open
#305 5 comments 0 reactions 0 assignees View on GitHub
feature rule
Dominant language
Java
Stars
159
Forks
31
Avg merge
5d 4h
Merged PRs (30d)
4

Description

### Prerequisites

- [X] This rule has not already been suggested.
- [X] This should be a new rule, not an improvement to an existing rule.
- [X] 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 :

```delphi
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.