Skip to content

NORETURN attribute on throwRuntimeError/throwLogicError #389

Closed
@MartinBonner

Description

@MartinBonner

I am running into Analysis errors when running Visual Studio 2015 Code Analysis on jsconcpp.

We could do with a conditional NORETURN attribute on the throw functions. That would:
a) suppress false positives from static code analysis
b) possibly improve optimization opportunities.

Note that although I am hitting this with VS, other people are quite likely to be running into issues on other platforms.

I am thinking of something like:

#if defined(__GNUC__) && __GNUC__ > "version"
    #define JSONCPP_NORETURN __attribute((noreturn))
#elif defined (_MSV_VER) && _MSC_VER > "version"
    #define JSONCPP_NORETURN __declspec(noreturn)
// More cases from people who understand different compilers.
#else
    #define JSONCPP_NORETURN
#endif
...
void JSCONCPP_NORETURN throwRuntimeError(std::string const& msg);

It would be nice if we could just use C++11 [[noreturn]], but annoyingly, Microsoft don't support that yet.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions