5 ms·
It's a C99 feature, and clang's the only compiler I know of that produces the diagnostic (and only in later versions) btw; I wrote this talk.
by rjek 14y ago
It's a C99 feature, and clang's the only compiler I know of that produces the diagnostic (and only in later versions)
btw; I wrote this talk.
- gjulianm 14y agoI didn't know that. To answer my previous question, clang doesn't fire a warning when passing pointers of any size to the function foo. And by the way, nice talk, it's great learning these dark secrets of C.
- adsr 14y agoBut a pointer is not the same thing as an array, a pointer does not carry the size of the allocated space which an array does in the same scope.
- rjek 14y agoThe compiler can't know at compile time with a naked pointer like it can with an array. [static 1] is handy to say it must not explicitly be NULL, as if it were optional, however.
- tobiasu 14y agoGood, because I was missing a slide: = Bitfields = Not even once. ;)
- rjek 14y agoEverybody knows about bitfields :)
- JoshTriplett 14y agoBitfields have some crazy fun dark corners, though. For instance, which values can this bitfield hold: int b:1; Signed two's-complement n-bit integers can hold values from 2^(n-1)-1 to -2^(n-1), so in theory it can hold 0 and -1, but many compilers get that one wrong. Always declare one-bit bitfields as unsigned. (The Sparse static analyzer will warn you about that one.)