Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
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-01-31-fix-fp-m9-3-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
`M9-3-3`: `MemberFunctionConstIfPossible.ql`:
- Fix FP reported in 467. Excluding candidates in uninstantiated templates.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ class ConstMemberFunctionCandidate extends NonConstMemberFunction {
not this instanceof Destructor and
not this instanceof Operator and
//less interested in MemberFunctions with no definition
this.hasDefinition()
this.hasDefinition() and
// For uninstantiated templates we have only partial information that prevents us from determining
// if the candidate calls non-const functions. Therefore we exclude these.
not this.isFromUninstantiatedTemplate(_)
}

/**
Expand Down
31 changes: 30 additions & 1 deletion cpp/autosar/test/rules/M9-3-3/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,35 @@ class Z22 : Z1 {
void f3() { this->a = 100; } // COMPLIANT
};

template <class T> class Array {
public:
T &back();

private:
T data[128];
unsigned int size;
};

template <class T, template <class...> class U> class Stack {
public:
T &Top() {
return this->data.back();
} // COMPLIANT[FALSE_NEGATIVE|TRUE_NEGATIVE] - exception not specified in the
// standard, we opt to not raise an issue because the template can be both
// compliant and non-compliant depending on instantiations.
private:
U<T> data;
};

using IntVectorStack = Stack<int, Array>;

void test_template() {
IntVectorStack s;

int i = s.Top();
}

class Z3 {
void f(int) = delete; // COMPLIANT
};
};
Comment thread
rvermeulen marked this conversation as resolved.