Skip to content

Shadowed Member in merge_patch #1339

@ax3l

Description

@ax3l
  • What is the issue you have?

Compiling in downstream projects with -Wshadow warns on void merge_patch(const basic_json& patch) shadowing a member of this.

https://github.com/nlohmann/json/blob/master/include/nlohmann/json.hpp#L7866

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?

Compile with Clang 5.0.0 and CXXFLAGS="-Wshadow".

  • What is the expected behavior?

Better not to shadow a member of this :)

  • And what is the actual behavior instead?

Throws a warning, e.g.: https://travis-ci.org/openPMD/openPMD-api/jobs/449795263

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]
     {

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?

We use release 3.4.0.

N/A

first seen by @franzpoeschel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions