[PATCH] D40720: No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17

Stephan Bergmann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 1 06:19:09 PST 2017


sberg created this revision.
Herald added a subscriber: kubamracek.

As discussed in the mail thread https://groups.google.com/a/isocpp.org/forum/#!topic/std-discussion/T64_dW3WKUk "Calling noexcept function throug non-noexcept pointer is undefined behavior?", such a call should not be UB.  However, Clang currently warns about it.

There is no cheap check whether two function type_infos only differ in noexcept, so pass those two type_infos as additional data to the function_type_mismatch handler (with the optimization of passing a null "static callee type" info when that is already noexcept, so the additional check can be avoided anyway).  For the Itanium ABI (which appears to only record noexcept information for pointer-to-function type_infos, not for function type_infos themselves), we then need to check the mangled names for occurrence of "Do" representing "noexcept".


https://reviews.llvm.org/D40720

Files:
  clang/lib/CodeGen/CGExpr.cpp
  compiler-rt/lib/ubsan/ubsan_handlers.cc
  compiler-rt/lib/ubsan/ubsan_handlers.h
  compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40720.125121.patch
Type: text/x-patch
Size: 7506 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171201/73ddc304/attachment.bin>


More information about the cfe-commits mailing list