Skip to content

Ternary operator crash #1034

@parfenuk

Description

@parfenuk

This simple code crashes:
string someStr;
json j = json::object();
// the next line crashes
j["someKey"] = someStr.empty() ? nullptr : someStr;

However, if I use standard if-else condition, everything is fine:
string someStr;
json j = json::object();
// the code below works ok
if (someStr.empty()) j["someKey"] = nullptr;
else j["someKey"] = someStr;

Also if S is not empty - both versions work.
Is it a bug or feature? :)

I'm using GNU C++ 14 compiler, IDE Xcode 9.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions