Skip to content

Commit fc92d82

Browse files
committed
added [[noreturn]] attribute to pybind11_fail
1 parent 87810d8 commit fc92d82

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

example/example12.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class PyExample12 : public Example12 {
5656
/* This function has no arguments. The trailing comma
5757
in the previous line is needed for some compilers */
5858
);
59-
throw std::runtime_error("this will never be reached");
6059
}
6160

6261
virtual void pure_virtual() {

include/pybind11/common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ struct error_already_set : public std::runtime_error { public: error_already_set
324324
/// Thrown when pybind11::cast or handle::call fail due to a type casting error
325325
struct cast_error : public std::runtime_error { public: cast_error(const std::string &w = "") : std::runtime_error(w) {} };
326326

327-
PYBIND11_NOINLINE inline void pybind11_fail(const char *reason) { throw std::runtime_error(reason); }
328-
PYBIND11_NOINLINE inline void pybind11_fail(const std::string &reason) { throw std::runtime_error(reason); }
327+
[[noreturn]] PYBIND11_NOINLINE inline void pybind11_fail(const char *reason) { throw std::runtime_error(reason); }
328+
[[noreturn]] PYBIND11_NOINLINE inline void pybind11_fail(const std::string &reason) { throw std::runtime_error(reason); }
329329

330330
NAMESPACE_END(pybind11)

0 commit comments

Comments
 (0)