cheekcatの日記: gcc の bug?
こういう test.c をコンパイルすると
1 int main(void)
2 {
3 static const int size = 16;
4 struct structA {
5 int foo[size];
6 };
7 struct structB {
8 int foo[16];
9 };
10 struct structA *ptrA;
11 struct structB *ptrB;
12
13 ptrA = (typeof(*ptrA) *) 0x12345;
14 ptrB = (typeof(*ptrB) *) 0x67890;
15
16 ptrA = ({ (typeof(*ptrA) *) 0x12345; });
17 ptrB = ({ (typeof(*ptrB) *) 0x67890; });
18
19 return 0;
20 }
% gcc -Wall test.c
test.c: In function ‘main’:
test.c:16: 警告: statement with no effect
と、なる。
多分、 定数を添字に使った配列を含む struct は ({}) の中でうまく typeof
がとれないのだろう。とりあえず x86_64-pc-linux-gnu-gcc-4.2.4 と
x86_64-pc-linux-gnu-gcc-4.3.1 で確認。
gcc の bug? More ログイン