{"action":"created","issue":{"url":"https://api.github.com/repos/nlohmann/json/issues/326","repository_url":"https://api.github.com/repos/nlohmann/json","labels_url":"https://api.github.com/repos/nlohmann/json/issues/326/labels{/name}","comments_url":"https://api.github.com/repos/nlohmann/json/issues/326/comments","events_url":"https://api.github.com/repos/nlohmann/json/issues/326/events","html_url":"https://github.com/nlohmann/json/issues/326","id":182217269,"number":326,"title":"Segmentation fault on saving json to file","user":{"login":"j-o-d-o","id":15958535,"avatar_url":"https://avatars.githubusercontent.com/u/15958535?v=3","gravatar_id":"","url":"https://api.github.com/users/j-o-d-o","html_url":"https://github.com/j-o-d-o","followers_url":"https://api.github.com/users/j-o-d-o/followers","following_url":"https://api.github.com/users/j-o-d-o/following{/other_user}","gists_url":"https://api.github.com/users/j-o-d-o/gists{/gist_id}","starred_url":"https://api.github.com/users/j-o-d-o/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j-o-d-o/subscriptions","organizations_url":"https://api.github.com/users/j-o-d-o/orgs","repos_url":"https://api.github.com/users/j-o-d-o/repos","events_url":"https://api.github.com/users/j-o-d-o/events{/privacy}","received_events_url":"https://api.github.com/users/j-o-d-o/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-10-11T09:31:57Z","updated_at":"2016-10-11T10:53:50Z","closed_at":null,"body":"I get a segmentation fault when saving a json data object to a file like this:\r\n\r\n```cpp\r\n#include <iostream>\r\n#include <fstream>\r\n#include \"json.hpp\"\r\n\r\nbool SaveToFile(nlohmann::json data) {\r\n\tstd::ofstream jsonFile;\r\n\t\t\r\n\tjsonFile.open(\"testFile.json\" , std::ofstream::out | std::ofstream::trunc);\r\n\tjsonFile << data;\r\n\tjsonFile.close();\r\n\t\r\n\treturn true;\r\n}\r\n\r\nint main() {\r\n\tstd::cout << \"========== Start Application ===========\" << std::endl;\r\n\t\r\n\treturn 0;\r\n}\r\n```\r\n\r\nThe problem is, I cant even debug anything. Because even if I don't use the function I get the segmentation fault. \r\nWhen changing: `jsonFile << data;` to `jsonFile << \"Test String\";`, I dont get any errors.\r\n\r\nI am using Visual GDB with gcc 4.9.2 (from here: http://gnutoolchains.com/raspberry/).\r\n\r\nPlease ask if any other information or clarification is needed!\r\n"},"comment":{"url":"https://api.github.com/repos/nlohmann/json/issues/comments/252881054","html_url":"https://github.com/nlohmann/json/issues/326#issuecomment-252881054","issue_url":"https://api.github.com/repos/nlohmann/json/issues/326","id":252881054,"user":{"login":"nlohmann","id":159488,"avatar_url":"https://avatars.githubusercontent.com/u/159488?v=3","gravatar_id":"","url":"https://api.github.com/users/nlohmann","html_url":"https://github.com/nlohmann","followers_url":"https://api.github.com/users/nlohmann/followers","following_url":"https://api.github.com/users/nlohmann/following{/other_user}","gists_url":"https://api.github.com/users/nlohmann/gists{/gist_id}","starred_url":"https://api.github.com/users/nlohmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nlohmann/subscriptions","organizations_url":"https://api.github.com/users/nlohmann/orgs","repos_url":"https://api.github.com/users/nlohmann/repos","events_url":"https://api.github.com/users/nlohmann/events{/privacy}","received_events_url":"https://api.github.com/users/nlohmann/received_events","type":"User","site_admin":false},"created_at":"2016-10-11T10:53:50Z","updated_at":"2016-10-11T10:53:50Z","body":"Ok. Thanks!"}}
{"actor":{"display_login":"nlohmann"}}