typeof and private data

Martin von Loewis martin@mira.isdn.cs.tu-berlin.de
Wed Dec 31 03:54:00 GMT 1997


The following code does compile with gcc 2.7.2, but not with egcs
(either 1.0, or 971225):

class KProcess 
{
public:
  bool normalExit();
private:
  int status;          
};
bool KProcess::normalExit()
{
  __typeof(status) foo;
  union { __typeof(  status  ) in; int i; } u;
  return false;
}

bash-2.00# g++ -v
Reading specs from /usr/lib/gcc-lib/i486-pc-linux-gnu/egcs-2.91.03/specs
gcc version egcs-2.91.03 971225 (gcc-2.8.0)
bash-2.00# g++ -c k.cc
k.cc: In method `bool KProcess::normalExit()':
k.cc:11: member `status' is a private member of class `KProcess'
k.cc:11: warning: ANSI C++ forbids declaration `in' with no type

Please note that the declaration of foo is OK; it is the declaration
of u.in which it complains about.

Is the code above correct GNU C++? If so, this is a bug in egcs.

This problem shows up when compiling KDE with glibc 2: the WIFEXITED
macro, when applied to a private member, produces the error message.

TIA,
Martin



More information about the Gcc-bugs mailing list