https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87547
Bug ID: 87547 Summary: G++ reports bad type names for bit-field members Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sandro.boehler at gmx dot de Target Milestone: --- Host: i686-linux-gnu Target: i686-linux-gnu Consider the following code: #include <typeinfo> struct S { unsigned int n4 : 4; unsigned int n12 : 12; }; void f(unsigned char) { std::cout << "uc" << std::endl; } void f(unsigned short) { std::cout << "us" << std::endl; } void f(unsigned int) { std::cout << "ui" << std::endl; } int main(int argc, char* argv[]) { S s; s.n4 = 0; s.n12 = 0; f(s.n4); f(s.n12); std::cout << typeid(s.n4).name() << std::endl; std::cout << typeid(s.n12).name() << std::endl; std::cout << typeid(unsigned char).name() << std::endl; std::cout << typeid(unsigned short).name() << std::endl; std::cout << typeid(unsigned int).name() << std::endl; return 0; } Expected output (according to standard [class.bit] (http://eel.is/c++draft/class.bit): "The bit-field attribute is not part of the type of the class member."): ui ui j j h t j Output produced with g++ (Ubuntu 8.1.0-5ubuntu1~16.04) 8.1.0 (initially discovered with 5.5.0): ui ui h t h t j So while the overload is selected correctly, typeid selects the bad type. I did not test separately, but assume the compiler showing same behaviour for C as well.