mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-28 07:48:14 +08:00
fbc365fa9e
P0012R1, accepted into C++17, makes a function’s “noexcept” (or “throw()”) specification part of its signature. GCC 7.2 provides a warning, -Wnoexcept-type, that is triggered when a function pointer type with an exception specification is used in pre-C++17 code in such a way as to pose an ABI incompatibility with C++17 code. https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/C_002b_002b-Dialect-Options.html#index-Wnoexcept-type Warnings are of the form: In file included from ../../util/misc/from_pointer_cast_test.cc:15:0: ../../util/misc/from_pointer_cast.h:64:1: error: mangled name for ‘typename std::enable_if<(std::is_pointer<From>::value && std::is_pointer<_Tp>::value), To>::type crashpad::FromPointerCast(From) [with To = const volatile void*; From = void* (*)(long unsigned int) throw ()]’ will change in C++17 because the exception specification is part of a function type [-Werror=noexcept-type] FromPointerCast(From from) { ^~~~~~~~~~~~~~~ ../../util/misc/from_pointer_cast.h:64:1: error: mangled name for ‘typename std::enable_if<(std::is_pointer<From>::value && std::is_pointer<_Tp>::value), To>::type crashpad::FromPointerCast(From) [with To = volatile void*; From = void* (*)(long unsigned int) throw ()]’ will change in C++17 because the exception specification is part of a function type [-Werror=noexcept-type] In Crashpad, this warning is triggered by the two FromPointerCast<>() variants that accept function pointer “From” arguments. This occurs when using glibc as the standard C library, since glibc declares its functions as “throw()”. FromPointerCast<>() is used with pointers to glibc functions such as malloc() and getpid(). The warning is disabled for the FromPointerCast<>() variants that would trigger it. The warning is not useful or actionable in this internal Crashpad code where ABI changes due to language version (including mangling changes) are not a concern. Clang 4.0 has the similar -Wc++1z-compat-mangling option (also available as -Wc++17-compat-mangling and the GCC-compatible -Wnoexcept-type in Clang 5.0) but it is not triggered by this pattern. Change-Id: Id293db3954be415f67a55476ca72bfb7d399aa3b Reviewed-on: https://chromium-review.googlesource.com/738292 Reviewed-by: Joshua Peraza <jperaza@chromium.org> Commit-Queue: Mark Mentovai <mark@chromium.org>