Declaring it volatile
Posted Aug 7, 2012 15:24 UTC (Tue) by
PaulMcKenney (subscriber, #9624)
In reply to:
Declaring it volatile by viro
Parent article:
ACCESS_ONCE()
I must admit that I have never used "typeof(({ printf("From typeof()\n"); j; })) k = 1;" to declare a variable "k" of the same type as "j", but gcc appears quite happy with it.
And yes, gcc also seems quite happy to leak types from "({...})":
#include <stdio.h>
int main(int argc, char *argv[])
{
int i = argc;
signed int j = i;
typeof(({ struct foo { int a; } q = { 1 }; printf("From typeof()\n"); q; })) k = { 2 };
printf("i = %d, j = %d, k.a = %d\n", i, j, k.a);
return 0;
}
Yow!!!
Fortunately for me, ACCESS_ONCE() does not depend on the semantics of typeof() applied to either "({...})"; or bitfields, although only because it is illegal to take the address of either of them. ;-)
(
Log in to post comments)