tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Strange sizeof construct


From: Chris Lattner
Subject: Re: [Tinycc-devel] Strange sizeof construct
Date: Tue, 13 Nov 2007 16:38:39 -0800


On Nov 13, 2007, at 3:39 PM, grischka wrote:

Could a C guru out there please tell me why the following works?
Extra points if you can explain why it makes sense.

#include <stdio.h>

int main(){
int arr[10];
printf("%d\n",sizeof arr[0]);  // ok
printf("%d\n",sizeof(arr[0])); // ok
printf("%d\n",sizeof(arr)[0]); // ok, but why?
return 0;
}

And what about that one:

    printf("%d\n",sizeof (0)[arr]);

Why wouldn't this work? These all seem to be explicitly allowed by the C99 grammar.

-Chris




reply via email to

[Prev in Thread] Current Thread [Next in Thread]