This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: typeid name of non-throwing function type


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).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]