Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions change_notes/2024-03-22-fix-fp-89-a8-4-7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `A8-4-7` - `InParametersForCheapToCopyTypesNotPassedByValue.ql`, `InParametersForCheapToCopyTypesNotPassedByReference.ql`:
- Fixes #89. Accidental floor rounding was applying to type size calculations.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ int wordSize() { result = max(VoidPointerType v | | v.getSize()) }
* Converts bytes to words
*/
bindingset[bytes]
int bytesToWords(int bytes) { result = bytes / wordSize() }
float bytesToWords(float bytes) { result = bytes / wordSize() }
Comment thread
knewbury01 marked this conversation as resolved.
Outdated

class TriviallyCopyableSmallType extends Type {
TriviallyCopyableSmallType() {
Expand Down
12 changes: 11 additions & 1 deletion cpp/autosar/test/rules/A8-4-7/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,14 @@ struct S5 {

void f15(S3 f15a) {} // COMPLIANT
void f17(S4 f17a) {} // NON_COMPLIANT (S4 has a non-trivial destructor)
void f18(S5 f18a) {} // COMPLIANT
void f18(S5 f18a) {} // COMPLIANT

#include <iostream>
class A8_4_7 {
public:
std::array<char, 20UL> values;
};
void fp_reported_in_82(
const A8_4_7 &a847) noexcept { // COMPLIANT - larger than 2 words
std::cout << a847.values[0] << std::endl;
}