Maciej Fijalkowski <fij...@gmail.com> writes: > On Tue, Feb 12, 2013 at 6:57 AM, Justin Bogner <m...@justinbogner.com> wrote: >> Armin Rigo <ar...@tunes.org> writes: >>> Ah, indeed. We declare most arrays as "itemtype x[1]", so gcc complains >>> when it can prove we do accesses at an index > 0. >> >> Is there a good reason not to use the C99 "itemtype x[]" or even the old >> GCC extension "itemtype x[0]"? These won't trigger this warning, which >> means we could leave it on in case a legitimate case crops up. >> >> As far as I know, the only noticeable difference between [], [0], and >> [1] for flexible arrays is that sizeof has different semantics, but >> that's usually not a big deal. > > I think we use sizeof. How is it better than just turning off the > warning actually? There are no legitimate cases
I'm not sure what you mean when you say there are no legitimate cases. In the cases where we define an array of length 1 it's true that these warnings aren't meaningful, but that's just because an array of length 1 (almost) always means we want a flexible array. On the other hand, for arrays with a meaningful length, I've only ever seen this warning point out legitimate bugs. Using flexible arrays instead of relying on, as Dennis Ritchie has referred to it, "unwarranted chumminess with the C implementation" makes the intention clearer. It avoids the issue without having to fight with the compiler or turn the warning off. I don't really see a downside, personally. Maybe I'm missing something here. _______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev