-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
internal compiler error (gcc7) #701
Comments
The test suite compiles without problem with g++-7 (Ubuntu 7.1.0-5ubuntu2~14.04) 7.1.0, see https://travis-ci.org/nlohmann/json/jobs/265058071. What OS are you using and which exact GCC version? Can you provide the source code that yields this error? |
I have commented out most of the lines in which I actually use the library (other than the include, and the field declaration) to narrow down the problem. I use gcc-7 (Ubuntu 7.1.0-5ubuntu2~16.04) 7.1.0 #ifndef CONFIG_CONFIGURATION_HPP_
#define CONFIG_CONFIGURATION_HPP_
#include "util/json.hpp"
#include <boost/lexical_cast.hpp>
#include <fstream>
class Configuration {
public:
Configuration();
virtual ~Configuration();
// Load the constant values from the JSON file
virtual void LoadProperties(std::string file_name);
// This is a test method which initializes constants to default
// values without the need to pass in a configuration file
virtual void LoadProperties();
inline std::string GetPropString(std::string key, std::string def) {
std::string field;
if (ContainsKey(key)) {
// field = json_obj_[key].get<std::string>();
} else {
field = def;
}
return field;
}
inline unsigned int GetPropInt(std::string key, unsigned int def) {
int field = 0 ;
if (ContainsKey(key)) {
// field = json_obj_[key].get<unsigned int>();
} else {
field = def;
}
return field;
}
inline unsigned long GetPropLong(std::string key, unsigned long def) {
long field = 0 ;
if (ContainsKey(key)) {
// field = json_obj_[key].get<unsigned long>();
} else {
field = def;
}
return field;
}
inline double GetPropDouble(std::string key, double def) {
double field = 0 ;
if (ContainsKey(key)) {
// field = json_obj_[key].get<double>();
} else {
field = def;
}
return field;
}
inline bool GetPropBool(std::string key, bool def) {
bool field = false;
if (ContainsKey(key)) {
// field = json_obj_[key].get<bool>();
} else {
field = def;
}
return field;
}
inline unsigned short GetPropShort(std::string key, unsigned short def) {
unsigned short field = 0 ;
if (ContainsKey(key)) {
// field = json_obj_[key].get<unsigned short>();
} else {
field = def;
}
return field;
}
inline bool IsInitialised() const {
return is_initialised_ == true;
}
protected:
// Guard fal.g: determines whether this block
// been initialized. No work should be done until executed
bool is_initialised_;
// Name of the file from which json was loaded
std::string config_file_name_;
// Json object
nlohmann::json json_obj_;
inline nlohmann::json LoadFile(std::string file_name) {
// std::ifstream file_stream(file_name);
// nlohmann::json json_file =nlohmann::json::parse(file_stream);
// return json_file;
return NULL;
}
inline bool ContainsKey(std::string key) {
assert(json_obj_!= NULL);
return false;
// return json_obj_.at(key)!=json_obj_.end();
}
};
#endif /* CONFIG_CONFIGURATION_HPP_ */ |
I copy-pasted your snippet and it compiles with my GCC (Debian 7.1.0-13) |
I can compile the code with g++-7 (Homebrew GCC 7.2.0) 7.2.0. |
Thanks for reporting, but since I cannot reproduce the error, I cannot do much about it. |
After dealing with the "using namespace std", I receive the following error when compiling json.hpp
/media/ncrooks/Data/Documents/PhD/morty/src/util/json.hpp: In instantiation of ‘static nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::escape_string(const string_t&) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::string_t = std::__cxx11::basic_string]’:
/media/ncrooks/Data/Documents/PhD/morty/src/util/json.hpp:8449:39: required from ‘void nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::dump(std::ostream&, bool, unsigned int, unsigned int) const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; std::ostream = std::basic_ostream]’
/media/ncrooks/Data/Documents/PhD/morty/src/util/json.hpp:2653:17: required from ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::string_t nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::dump(int) const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::string_t = std::__cxx11::basic_string]’
/media/ncrooks/Data/Documents/PhD/morty/src/util/json.hpp:12951:25: required from here
/media/ncrooks/Data/Documents/PhD/morty/src/util/json.hpp:8228:25: internal compiler error: in type_unification_real, at cp/pt.c:19128
for (const char m :
^~~
0x5f8748 type_unification_real
../../src/gcc/cp/pt.c:19128
0x5dfcb3 do_auto_deduction(tree_node*, tree_node*, tree_node*, int, auto_deduction_context, tree_node*, int)
../../src/gcc/cp/pt.c:25417
0x5e0375 do_auto_deduction(tree_node*, tree_node*, tree_node*)
../../src/gcc/cp/pt.c:25309
0x6297a3 build_range_temp
../../src/gcc/cp/parser.c:11585
0x631485 cp_convert_range_for(tree_node*, tree_node*, tree_node*, tree_node*, unsigned int, bool)
../../src/gcc/cp/parser.c:11682
0x5e7364 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15880
0x5e7bc5 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15719
0x5e7a5b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15945
0x5e85d5 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15915
0x5e7bc5 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15719
0x5e7a5b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15945
0x5e7bc5 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15719
0x5e7a5b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15945
0x5e7b3c tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15965
0x5e737e tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15882
0x5e7bc5 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15719
0x5e7a5b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15945
0x5e61f2 instantiate_decl(tree_node*, bool, bool)
../../src/gcc/cp/pt.c:22897
0x5ff45b instantiate_pending_templates(int)
../../src/gcc/cp/pt.c:23018
0x61f250 c_parse_final_cleanups()
../../src/gcc/cp/decl2.c:4526
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
The text was updated successfully, but these errors were encountered: