Skip to content
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

Mark LOG(FATAL) with [[noreturn]] #28

Closed
orian opened this issue May 18, 2015 · 0 comments
Closed

Mark LOG(FATAL) with [[noreturn]] #28

orian opened this issue May 18, 2015 · 0 comments

Comments

@orian
Copy link

orian commented May 18, 2015

Example:

int Find(const std::vector<int>& x) {
  // proper code with return statement for all correct input values
  LOG(FATAL) << "x is bad";
}

The above code during compilation shows a warning:

warning: control may reach end of non-void function [-Wreturn-type]

The warning in general is useful, what about marking a subclass responsible for fatal messages with [[noreturn]]?

Sources:
[1] http://stackoverflow.com/questions/12146772/can-i-tell-the-compiler-to-consider-a-control-path-closed-with-regards-to-return
[2] http://en.cppreference.com/w/cpp/language/attributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants