https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68604
Bug ID: 68604
Summary: typeid does not allow an id-expression that denotes a
non-static data member
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: yaghmour.shafik at gmail dot com
Target Milestone: ---
Given the following simplified example from this Stackoverflow question
http://stackoverflow.com/q/28053640/1708801 :
#include <iostream>
#include <typeinfo>
struct A{ int i; };
int main()
{
std::cout << typeid(A::i).name() << '\n';
}
gcc produces the following error:
error: invalid use of non-static data member 'A::i'
std::cout << typeid(A::i).name() << '\n';
^
As far as I can tell since this is an unevaluated operand like in sizeof and
decltype this should should be ok. clang accepts this code.