protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Add explicit abort() at the end of AlignFail (Backports #10188)

Open drok opened this issue 2 years ago • 1 comments

GCC cannot infer that LogMessage::Finish() (called indirectly by GOOGLE_LOG(FAIL) in AlignFail) exits program when level_ == LOGLEVEL_FATAL. Compilation will create a warning in projects importing the library for debug builds. The attribute cannot be individually assigned to LogMessage::Finish() because it does return conditionally of the log level. Tried with GCC 9.3.0 and GCC 12.1.0.

This change adds an explicit abort() for compiler to clearly understand this does not return, and enables [[noreturn]] for MSVC as well.

Cherry-picked from: 1e9d43fe711b46bcb9bb82849d495f137c9d1ef8 Backports PR-#10188 from 74abfe447

drok avatar Jan 08 '23 16:01 drok

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Jan 08 '23 16:01 google-cla[bot]