Skip to content

Json::Exception broken #216

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

Closed
Dani-Hub opened this issue Mar 9, 2015 · 2 comments
Closed

Json::Exception broken #216

Dani-Hub opened this issue Mar 9, 2015 · 2 comments

Comments

@Dani-Hub
Copy link
Contributor

Dani-Hub commented Mar 9, 2015

The new exception class Json::Exception contains a data member of reference type. That means the initializing object is required to have a longer life-time than the exception class. But this does not happen: The class is always constructed by temporaries, so there are nasal daemons all around!

I do not understand the reason to why a member reference has been chosen, but that is clearly wrong here. I suggest to replace the reference member by a normal non-reference member of type std::string that copies the provided argument.

That being said: Why does the public header value.h declare the internal exception types and the corresponding factory functions? It would seem better (regarding implementation encapsulation) to move these declarations instead into an internal header (part of src, not part of include).

Dani-Hub added a commit to Dani-Hub/jsoncpp that referenced this issue Mar 9, 2015
@Dani-Hub
Copy link
Contributor Author

Dani-Hub commented Mar 9, 2015

A patch for the most serious problem (The reference member) has been pushed as fix candidate.

cdunn2001 pushed a commit that referenced this issue Mar 9, 2015
from "reference to string" to "string" (Resolves the most serious part of issue #216)
@cdunn2001
Copy link
Contributor

Ugh! On Linux, I would run valgrind always. On the Mac, I have to be perfect, which I am not. I need to find a practical memory-checker.

Anyway, I pulled that commit. We still want const, but good catch on the reference. Don't know what I was thinking. Late night commit? Code-reviews wouldn't hurt.

I don't have time right now to look at the other issues. But maybe you can research when <cmath> became available in gcc. At the moment, legacy users can still get bug-fixes from the 0.*.* branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants