Skip to content

compiler warning: "not return a value" #2917

Description

@GaRaOne

What is the issue you have?

const typename object_t::key_type& key() const
nlohmann/json.hpp:11996:5: warning: non-void function does not return a value in all control paths [-Wreturn-type]

static ReferenceType get_ref_impl(ThisType& obj)
nlohmann/json.hpp:20017:5: warning: non-void function does not return a value in all control paths [-Wreturn-type]

reference operator[](T* key)
nlohmann/json.hpp:20925:5: warning: non-void function does not return a value in all control paths [-Wreturn-type]

const_reference operator[](const typename object_t::key_type& key) const
nlohmann/json.hpp:20877:5: warning: non-void function does not return a value in all control paths [-Wreturn-type]

and many more... mostly looking like:

    ReturnType fooBar( xxx )
    {
        if (JSON_HEDLEY_LIKELY( xxx ))
        {
          return xxx;
        }

        JSON_THROW( xxx );
    }

Please describe the steps to reproduce the issue.

  1. use custom JSON_THROW_USER without exceptions
  2. compile

What is the expected behavior?

no warnings

Which compiler and operating system are you using?

  • Compiler: clang
  • Operating system: ubuntu 21.04

Which version of the library did you use?

  • latest release version 3.9.1
  • other release - please state the version: ___
  • the develop branch

i'm not sure if this is intentional behavior. however, it floods the compiler output.
is there a trick to keep in mind when adding your own JSON_THROW?

ps: thanks for the awesome library. great work

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions