This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: typeid name of non-throwing function type
- From: Stephan Bergmann <sbergman at redhat dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 21 Dec 2017 07:52:36 +0100
- Subject: Re: typeid name of non-throwing function type
- Authentication-results: sourceware.org; auth=none
- References: <ed1ff555-f7da-68e5-61b6-0e779e101a6c@redhat.com>
On 12/20/2017 03:48 PM, Stephan Bergmann wrote:
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)?
Thinking a bit more about it, I think that's rather a bug in GCC, right?
~ cat test72.cc
#include <iostream>
#include <typeinfo>
void f1();
void f2() noexcept;
int main() { std::cout << (typeid(f1) == typeid(f2)) << '\n'; }
~ g++ -std=c++17 test72.cc
~ ./a.out
1
should print "0" instead of "1" (like the version does that compares
(typeid(&f1) == typeid(&f2))
instead).