24-11-2022, 01:41 PM
(This post was last modified: 25-11-2022, 09:18 AM by vanhuynh.
Edit Reason: Formatting, remove unintended emojis
)
Hello,
Our team uses a static analysis tool for ASIL-B compliance. The tool warns about violation of rule A20-8-2/A20-8-3 when a non-owning pointer is returned from a function:
However, I do not want to express exclusive or shared ownership. Is the warning correct or a false-positive?
Our team uses a static analysis tool for ASIL-B compliance. The tool warns about violation of rule A20-8-2/A20-8-3 when a non-owning pointer is returned from a function:
Code:
template <uint64_t CAPACITY>
class FixedCapacityBuffer {
std::array<uint8_t, CAPACITY> buffer;
uint64_t length;
public:
uint8_t* Data() const noexcept { return buffer.data(); } //////////////< Violation of rule A20-8-2/A20-8-3?
// ...
};
Code:
Rule A20-8-3: "A unique_ptr shall be used to represent exclusive ownership."
Rule A20-8-3: "A std::shared_ptr shall be used to represent shared ownership."
However, I do not want to express exclusive or shared ownership. Is the warning correct or a false-positive?