This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
typeid name of non-throwing function type
- From: Stephan Bergmann <sbergman at redhat dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 20 Dec 2017 15:48:25 +0100
- Subject: typeid name of non-throwing function type
- Authentication-results: sourceware.org; auth=none
I see with any recent GCC (when targeting the Itanium C++ ABI),
$ cat test.cc
#include <iostream>
#include <typeinfo>
void f() noexcept;
int main() { std::cout << typeid(f).name() << '\n'; }
$ g++ -std=c++17 test.cc
$ ./a.out
FvvE
that the function type's mangling doesn't contain the noexcept specifier
(in which case it would be "DoFvvE").
Is that a deliberate decision in GCC, or does it just happen by accident
(as for function pointer types, the Itanium ABI encodes noexcept
specifiers at the __pointer_type_info, not at the underlying
__function_type_info)?
I'm asking in the context of Clang patch
<https://reviews.llvm.org/D40720> "No -fsanitize=function warning when
calling noexcept function through non-noexcept pointer in C++17". Clang
happens to produce type_info for the noexcept-annotated function type
(with "DoFvvE" name) in the above example, and not doing so (and instead
behaving like GCC does) would be one way to solve the issue I want to
fix with that patch.