integrated-application-development / integrated-application-development/sonar-delphi
Detect that a function pointer parameter has not the right size
- 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
Assessment
This issue has not been assessed yet.