https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80744
--- Comment #4 from Jonny Grant <jg at jguk dot org> --- Hi Martin Thank you for your reply. I appreciate that GCC isn't a static analyser.... But I think (C) is probably easier to follow though if GCC was extended, and (A) std::string harder, as needs knowledge of that container... the static instrumented code would need to call mystring.size() and see what the value would be? int main() { std::string empty; test_func(0, empty) } I've attached a test case where (B) is not detected, because "const" is removed.