Hello Florian, I tried to check your assumption. I prepared a small code snipper which is compiled successfully. I think, it may be considered as some "evidence".
autobld@pavo:base> cat simple.c int main() { int x = 3; __typeof__(x) y = 4; long z; z = (__typeof__(z)) (x + y); char * s, * p; p = (__typeof__(s))malloc(10); return 0; } autobld@pavo:base> cc_r -o simple.o -c simple.c; echo $? 0 autobld@pavo:base> cc_r -o simple.o -q64 -c simple.c; echo $? 0 autobld@pavo:base> cc_r -qversion C for AIX version 6.0.0.0 So, it looks like compiler understands the usage of __typeof__ in two use cases: a) as a type cast, b) as a type in the variable declaration. So far I incline to think that it is a problem of compiler itself, what do you think? -- Best Regards, Alexander. 2016-10-31 10:05 GMT+01:00 Florian Weimer <fwei...@redhat.com>: > On 10/28/2016 05:13 PM, TestRealTime . wrote: > >> Hello, >> >> I would like to report about two (probably, self-connected) bugs in the >> __typeof__ C function. >> These bugs are reproduced when I am trying to compile a simple code with >> XLC compiler on AIX 5.2. Please, look at the code snippets below. >> >> 1. typeof_example_1.c >> long Func(int x) { return x; } >> int main() >> { >> int y, z = 1; >> y = (__typeof__(Func(z)))0; >> return 0; >> } >> >> cc_r typeof_example_1.c >> "typeof_example_1.c", line 5.26: 1506-045 (S) Undeclared identifier z. >> >> The 'z' variable is obviously defined, so "Undeclared identifier" message >> is wrong. >> > > Do you have any evidence that the compiler supports __typeof__ at all? > Maybe the compiler treats __typeof__ as an implicitly declared function. > > What is interesting, we use cc_r, but not xlc binary in our build system >> (it is probably due to historical reasons and persons who can answer me >> why >> exactly cc_r have gone many years ago). But with xlc both code snippets >> also fail, however with other error messages (no matter, 32 or 64bit). >> xlc typeof_example_1.c >> "typeof_example_1.c", line 5.30: 1506-275 (S) Unexpected text integer >> constant encountered. >> xlc typeof_example_2.c >> "typeof_example_2.c", line 5.41: 1506-275 (S) Unexpected text z >> encountered. >> "typeof_example_2.c", line 5.45: 1506-275 (S) Unexpected text integer >> constant encountered. >> > > Those syntax errors are consistent with not supporting __typeof__ at all. > The expression parts which contain __typeof__ are not recognized as types, > and so the expression is not recognized as a cast. > > Florian >