vingeldal added a comment. In D77461#1963166 <https://reviews.llvm.org/D77461#1963166>, @lebedev.ri wrote:
> https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Ri-global > is in "Interfaces" section, it only covers inter-procedural stuff. > Diagnosing function-local static non-const variable is a plain > false-positive diagnostic. I don't follow your train of thought. Could you please elaborate on why you think this must be a false positive? My reason for hesitating to call this a false positive is that this pattern does cause a hidden dependency between users of the function, hence it clearly goes against the short and simple rationale given for this rule: "Non-const global variables hide dependencies and make the dependencies subject to unpredictable changes." It is arguably unconventional in C++ to make a free function statefull, if one wants to make a function stateful there is the obvious alternative of making it a member function of a class -which would allow you to achieve the same thing but with more explicitly expressed statefullness in the interface and stronger encapsulation of the state. Not sure if it makes any difference but note that this check also covers rule R.6 which is the exact same rule but in a different context. https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rr-global Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77461/new/ https://reviews.llvm.org/D77461 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits