Skip to content

0.y.z build fails with gcc 6.3 #600

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
fedorov opened this issue Apr 7, 2017 · 15 comments
Closed

0.y.z build fails with gcc 6.3 #600

fedorov opened this issue Apr 7, 2017 · 15 comments

Comments

@fedorov
Copy link

fedorov commented Apr 7, 2017

Errors:

/home/work/dcmqi/jsoncpp/jsoncpp.cpp:234:14: error: 'scoped_ptr' in namespace 'std' does not name a template type
 typedef std::scoped_ptr<CharReader> const  CharReaderPtr;
              ^~~~~~~~~~
/home/work/dcmqi/jsoncpp/jsoncpp.cpp: In function 'bool Json::parseFromStream(const Json::CharReader::Factory&, std::istream&, Json::Value*, std::__cxx11::string*)':
/home/work/dcmqi/jsoncpp/jsoncpp.cpp:2007:3: error: 'CharReaderPtr' was not declared in this scope
   CharReaderPtr const reader(fact.newCharReader());
   ^~~~~~~~~~~~~
/home/work/dcmqi/jsoncpp/jsoncpp.cpp:2008:10: error: 'reader' was not declared in this scope
   return reader->parse(begin, end, root, errs);
          ^~~~~~
/home/work/dcmqi/jsoncpp/jsoncpp.cpp: At global scope:
/home/work/dcmqi/jsoncpp/jsoncpp.cpp:3803:14: error: 'scoped_ptr' in namespace 'std' does not name a template type
 typedef std::scoped_ptr<StreamWriter> const  StreamWriterPtr;
              ^~~~~~~~~~
/home/work/dcmqi/jsoncpp/jsoncpp.cpp: In function 'std::__cxx11::string Json::writeString(const Json::StreamWriter::Factory&, const Json::Value&)':
/home/work/dcmqi/jsoncpp/jsoncpp.cpp:4924:3: error: 'StreamWriterPtr' was not declared in this scope
   StreamWriterPtr const writer(builder.newStreamWriter());
   ^~~~~~~~~~~~~~~
/home/work/dcmqi/jsoncpp/jsoncpp.cpp:4925:3: error: 'writer' was not declared in this scope
   writer->write(root, &sout);
   ^~~~~~
/home/work/dcmqi/jsoncpp/jsoncpp.cpp: In function 'std::ostream& Json::operator<<(std::ostream&, const Json::Value&)':
/home/work/dcmqi/jsoncpp/jsoncpp.cpp:4931:3: error: 'StreamWriterPtr' was not declared in this scope
   StreamWriterPtr const writer(builder.newStreamWriter());
   ^~~~~~~~~~~~~~~
/home/work/dcmqi/jsoncpp/jsoncpp.cpp:4932:3: error: 'writer' was not declared in this scope
   writer->write(root, &sout);
   ^~~~~~
@cdunn2001
Copy link
Contributor

Old version? We do not use scoped_ptr:

  57 #if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
  58 typedef std::unique_ptr<CharReader> CharReaderPtr;
  59 #else
  60 typedef std::auto_ptr<CharReader>   CharReaderPtr;
  61 #endif

@fedorov
Copy link
Author

fedorov commented Apr 8, 2017

@cdunn2001 perhaps I am doing something wrong. What I did is I generated amalgamated header from the current 0.y.z branch, and the resulting jsoncpp.cpp clearly contains scoped_ptr, see https://github.com/fedorov/dcmqi/blob/update-jsoncpp/jsoncpp/jsoncpp.cpp#L233-L237. What am I missing?

@cdunn2001
Copy link
Contributor

Well, yes, there was std::scoped_ptr on the old 0.y.z branch, but only for gcc>=6:

  57 #if __GNUC__ >= 6
  58 typedef std::scoped_ptr<StreamWriter> const  StreamWriterPtr;
  59 #else
  60 typedef std::auto_ptr<StreamWriter>          StreamWriterPtr;
  61 #endif

@cdunn2001
Copy link
Contributor

Hmm. Maybe gcc 6.3 dropped std::scoped_ptr, or maybe you're building for C++11 (you could check the compilation flags actually used).

If you cannot find a work-around, the best solution is to switch to the master branch. Patches to 0.y.z are possible, but the whole purpose of that branch is to maintain compatibility with a variety of old compilers and systems. master is C++11 only (though it might currently still work with C++0x).

@fedorov
Copy link
Author

fedorov commented Apr 9, 2017

We intentionally used 0.y.z to get rid of C++11 requirement. It's been working fine for our CI and most users (see CI banners on https://github.com/qiicr/dcmqi), but recently we got a report that it breaks with gcc 6.3. Looking here, it appears that the default mode in gcc 6 has been changed to -std=gnu++14, so perhaps this is the reason. I will experiment a bit more and report here.

@cdunn2001
Copy link
Contributor

That's the difficulty of upgrading some things but not others.

However, if the only problem is scoped_ptr, we could back-port the change to unique_ptr.

@nolden
Copy link

nolden commented Apr 10, 2017

With gcc 6 I successfully built recent master using -std=c++03, so I guess there is no C++11 code yet in jsoncpp?

@cdunn2001
Copy link
Contributor

cdunn2001 commented Apr 18, 2017

Yes, but that's the master branch. fedorov is using the 0.y.z branch, I think...

... Oh, I see. You're saying they could use master and simply set --std=c++03. Yes, for now that would work. We reserve the right to add C++11 features eventually, but you can always lock the version if that happens.

@Phibonacci
Copy link

I do not find anything about scoped_ptr ever being part of the STL. It is part of boost but I don't believe std::scoped_ptr ever compiled.

Checking the GCC version would be wrong anyway as it does not guarantee the program is compiled with the latest C++ version / ABI.

@Phibonacci
Copy link

Can you rollback this commit ?

#413

@Phibonacci
Copy link

I just realized the master version does not match the last release of the 0.x.y (0.10.6) which is using scoped_ptr. The tip of x.y.z is currently using std::unique_ptr<> with the macro JSON_HAS_UNIQUE_PTR which is never define.

Can you create a new release to avoid further confusion?

@cdunn2001
Copy link
Contributor

A new release? We'll do that soon. But is master wrong?

We try not to touch the 0.y.z branch, since it is quite old.

@Phibonacci
Copy link

As stated in #828 0.x.y branch looks fine. A new release should fix this issue.

@cdunn2001
Copy link
Contributor

A new "0.y.z" release, based on the tip of the 0.y.z branch?

@wanliqun
Copy link

Great for the new update here:
https://github.com/open-source-parsers/jsoncpp/releases/tag/0.10.7

I can even compile the project with gcc 8.2 now.

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

5 participants