-
Notifications
You must be signed in to change notification settings - Fork 780
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
Cereal 1.2.0 - “looser throw specifier” error using JSON or XML archive #311
Comments
Can you post the full command you are compiling with? I can't reproduce this with g++-4.7.4 using the following test case, with either XML or JSON: #include <iostream>
#include <cereal/archives/json.hpp>
#include <cereal/archives/xml.hpp>
struct Window
{
int height;
int width;
bool enable;
template <class Archive>
void serialize( Archive & ar )
{
ar( CEREAL_NVP(height), CEREAL_NVP(width),
CEREAL_NVP(enable) );
}
};
int main()
{
{
cereal::XMLOutputArchive ar( std::cout );
Window w = {101, 200, true};
ar( cereal::make_nvp("windows", w) );
}
} Can you compile the unit tests successfully? When you updated cereal, did you completely remove your old installation? |
I don't have a local copy of the source right now, but I WILL point out what looks like an error in the code that could have caused this. Line 258 of cereal/helpers.hpp does this: HOWEVER, json.hpp line 158 contains: Seems that CEREAL_NOEXCEPT should be after that as well, since we're inheriting from a virtual destructor. xml.hpp line 161 has this same problem: I'm actually REALLY confused though, since the error message refers to InputArchives, yet the code doesn't use them, and there doesn't seem to be any destructors for Json input archive defined. Line 402 (from the error message above) is the class header. @DaemonPulsar : Can you change json.hpp:158 to be: |
@erichkeane Yeah I noticed that as well - it should probably be changed, though I had the understanding that destructors are implicitly |
@AzothAmmo Note that GCC4.7 is horrible for C++11 implementation, so a lot of things like that could likely not be the case in something that old. |
I did not have access to my computer this wee-end, but @erichkeane I don't know a lot about exception mechanism but I tried and it removed the first error. |
I found this bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51452 which confirms my suspicion from above, the destructors weren't default-noexcept in the 4.7 branch (though perhaps backported to 4.7.4?). @DaemonPulsar That would make me think that JSONInputArchive needs the following line added to it: |
ok, so ...
The code you provide fails with:
@erichkeane adding
If I remove Applying the same strategy on XML archive, it compiles OK and provide the following output
which seems to be ok. To sumup:json.hpp
xml.hpp
Can I safely use this patch for now ? and thanks for your help ! |
The non-specified JSONInputArchie concerns me a little, since I fear you'll get a linker error when trying to use it. If you don't, then either something nasty is happening, or something I don't understand. I'd say at LEAST give it an empty body ( {}). Otherwise, it seems that this should be a fine patch. Alternatively, if you have the ability, you could upgrade compilers to something more recent. |
Of course you're right, linker is not really happy to deal with a non-specified destructor. Correct version is I'll try to get a more recent compiler, also. Thank again |
I'll commit the |
Should be fixed on develop, I'll push it out as a release either this weekend or on Monday along with the threading stuff from #320. |
also opened on stackoverflow:
http://stackoverflow.com/questions/38267962/cereal-1-2-0-looser-throw-specifier-error-using-json-or-xml-archive
Hello all,
I just moved on Cereal 1.2.0 (moved from 1.1.2), and I obtain a compilation error when using JSONOutputArchive or XMLOutputArchive (i.e. including either "cereal/archives/json.hpp" or "cereal/archives/xml.hpp")
(example is with JSON archive but I have the same behavior using XML archive)
I compile using -std=c++11, with gcc version 4.7.3
Exact errors are :
I do need a std::string so I can't move to binary or portable_binary archive.
Is anyone else experienced this error using Cereal 1.2.0 ?
Did I miss something somewhere ? I did not change my code so I can say basically "it compiles with 1.1.2 and not 1.2.0"
Thanks !
The text was updated successfully, but these errors were encountered: