This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
typeof and bitfields
- From: Matt Austern <austern at apple dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 13 Jan 2005 15:56:00 -0800
- Subject: typeof and bitfields
Consider the following code:
struct X { int n : 1; };
void foo() { struct X x; typeof(x.n) tmp; }
With 3.3 it compiles both as C and as C++. With 4.0 it still compiles
as C++, but it fails when compiled as C with the error message:
foo.c:2: error: 'typeof' applied to a bit-field
This was obviously a deliberate change. However, I don't see any
mention about it in the part of the manual that documents typeof. I
also can't guess why this should be different in C and in C++, or what
the rationale for the change might have been in the first place. Sure,
applying sizeof or alignof to a bit-field makes no sense. But typeof?
X::n has a perfectly good type, as the C++ compiler understands.
I was tempted to just file a bug report, on the grounds that this is a
regression (an undocumented change in the behavior of a language
feature that causes some code that used that feature to break), but
perhaps there's some rationale for the change that I'm just not seeing.
--Matt