Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build warnings: shadowing exception id #776

Closed
pvleuven opened this issue Oct 10, 2017 · 8 comments
Closed

Build warnings: shadowing exception id #776

pvleuven opened this issue Oct 10, 2017 · 8 comments
Labels
platform: icc related to Intel compiler solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@pvleuven
Copy link

Hi,

I get a bunch of build warnings (see below) that inform on hiding the exception member 'id'. To me it seems the member is not needed as the id is always passed through the calling functions. Looks like a potential source of trouble to me.

Best regards,

Peter

warnings:
In file included from .*******: ********json/json.hpp(209): warning #3280: declaration hides member "nlohmann::detail::exception::id" (declared at line 204)
static std::string name(const std::string& ename, int id)
^
********json/json.hpp(273): warning #3280: declaration hides member "nlohmann::detail::exception::id" (declared at line 204)
static parse_error create(int id, std::size_t byte_, const std::string& what_arg)
^
********json/json.hpp(337): warning #3280: declaration hides member "nlohmann::detail::exception::id" (declared at line 204)
static invalid_iterator create(int id, const std::string& what_arg)
^
********json/json.hpp(388): warning #3280: declaration hides member "nlohmann::detail::exception::id" (declared at line 204)
static type_error create(int id, const std::string& what_arg)
^
********json/json.hpp(431): warning #3280: declaration hides member "nlohmann::detail::exception::id" (declared at line 204)
static out_of_range create(int id, const std::string& what_arg)
^
********json/json.hpp(469): warning #3280: declaration hides member "nlohmann::detail::exception::id" (declared at line 204)
static other_error create(int id, const std::string& what_arg)

@nlohmann
Copy link
Owner

Thanks for reporting. Is this an ICC warning?

@theodelrieu
Copy link
Contributor

Indeed, troubles ahead! I didn't take a detailed look to 3.0 exceptions but I think the member id is useful, especially when catching.

The naming convention I usually have is to prefix private member variables with an underscore.

@nlohmann nlohmann added the platform: icc related to Intel compiler label Oct 10, 2017
@nlohmann
Copy link
Owner

@theodelrieu In class exception, id is a public member. Would the error be fixed if I rename parameter id of function name?

@theodelrieu
Copy link
Contributor

Yep that will suffice

nlohmann added a commit that referenced this issue Oct 13, 2017
@nlohmann
Copy link
Owner

@pvleuven Could you please check if d300a8e fixes the warnings?

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Oct 13, 2017
@nlohmann
Copy link
Owner

Can I close this issue?

@pvleuven
Copy link
Author

pvleuven commented Oct 17, 2017

Yes it works, and I didn't mean to close it, I'll leave that to you, thanks!

@pvleuven pvleuven reopened this Oct 17, 2017
@nlohmann
Copy link
Owner

Thanks for checking back!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: icc related to Intel compiler solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

3 participants