You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
single_include/nlohmann/json.hpp:
In member function ‘void nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::merge_patch(const nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>&)’:
single_include/nlohmann/json.hpp:20126:5: error: declaration of ‘patch’ shadows a member of 'this' [-Werror=shadow]
{
Which compiler and operating system are you using? Is it a supported compiler?
Clang 5.0.0 on Travis CI (Ubuntu 14.04)
Did you use a released version of the library or the version from the develop branch?
Thanks for reporting. I do not like such warnings, because in the end they make the code "uglier", because I think it is fine to both have a member function called patch and a function parameter patch. But I think one can fix this by changing the parameter name to p or something...
Thanks for your feedback! Yes, I know that this "uglifies" the code a little by e.g. introducing consequent prefixes for members or the like in most cases... But I also got bitten quite a bit by shadowed vars in the past in large projects which are hard to catch sometimes.
If you are ok with that, I would really just rename the parameter name: #1346
Compiling in downstream projects with
-Wshadow
warns onvoid merge_patch(const basic_json& patch)
shadowing a member ofthis
.https://github.com/nlohmann/json/blob/master/include/nlohmann/json.hpp#L7866
Compile with Clang 5.0.0 and
CXXFLAGS="-Wshadow"
.Better not to shadow a member of
this
:)Throws a warning, e.g.: https://travis-ci.org/openPMD/openPMD-api/jobs/449795263
Clang 5.0.0 on Travis CI (Ubuntu 14.04)
develop
branch?We use release 3.4.0.
N/A
first seen by @franzpoeschel
The text was updated successfully, but these errors were encountered: