The static analyzer is currently unaware of types defined in the standard library with a valid and specified state after calling move, resulting in false positives.
According to the standard, A moved from vector is:
Guaranteed to be empty
Has it's allocator moved from, which if the allocator was std::allocator is a no-op and as such results in a valid state.
However the static-analyzer complains that after the call to eat, a is left in a valid but unspecified state, despeite the fact its known to be in a valid and empty state.
Ideally the analyzer should be aware of standard library types which are left in a valid and specified state after moves, and It should also be aware of their allocators when determining their state
The static analyzer is currently unaware of types defined in the standard library with a valid and specified state after calling move, resulting in false positives.
In this example:
According to the standard, A moved from vector is:
std::allocator
is a no-op and as such results in a valid state.However the static-analyzer complains that after the call to
eat
,a
is left in a valid but unspecified state, despeite the fact its known to be in a valid and empty state.Ideally the analyzer should be aware of standard library types which are left in a valid and specified state after moves, and It should also be aware of their allocators when determining their state
https://godbolt.org/z/xrjeoeqhM