Remix.run Logo
on_the_train 4 hours ago

But using the deref op is deliberately unsafe, and never used without a check in practice. This would neither pass a review, nor static analysis.

canyp 4 hours ago | parent | next [-]

GP picked the less useful of the two examples. The other one is a use-after-move, which static analysis won't catch beyond trivial cases where the relevant code is inside function scope.

I also agree with them: I am pro-C++ too, but the current standard is a fucking mess. Go and look at modules if you haven't, for example (don't).

mohinder 4 hours ago | parent | prev | next [-]

> This would neither pass a review, nor static analysis

I beg to differ. Humans are fallible. Static analysis of C++ cannot catch all cases and humans will often accept a change that passes the analyses.

einpoklum 3 hours ago | parent [-]

> Static analysis of C++ cannot catch all cases

You're ignoring how static analysis can be made to err on the side of safety rather than promiscuity.

Specifically, for optional dereferencing, static analysis can be made to disallow it unless it can prove the optional has a value.

IshKebab 3 hours ago | parent | prev [-]

> never used without a check in practice

Ho ho ho good one.