It would be nice to fix the "array subscript is above array bounds" warning spam for 1.4.0. They make up 90% of the warnings.
Apart from those, theres 25 more warning blocks to fix, most of them unused-but-set-variables.
JL
Jerome Leclanche adys.wh@gmail.com wrote:
It would be nice to fix the "array subscript is above array bounds" warning spam for 1.4.0. They make up 90% of the warnings.
The compiler is misguided, you can safely ignore those warnings.
On Oct 12, 2011, at 10:11 AM, Dmitry Timoshkov wrote:
Jerome Leclanche adys.wh@gmail.com wrote:
It would be nice to fix the "array subscript is above array bounds" warning spam for 1.4.0. They make up 90% of the warnings.
The compiler is misguided, you can safely ignore those warnings.
My understanding is that accessing element n or greater in an array[n] is undefined behavior, but declaring a huge array and allocating only part of it is valid.
Josh
On Wed, Oct 12, 2011 at 11:22 PM, Josh Juran josh@iswifter.net wrote:
My understanding is that accessing element n or greater in an array[n] is undefined behavior, but declaring a huge array and allocating only part of it is valid.
It's a commonly used pattern in C. You declare a size-one array at the end of a structure, then you allocate enough memory to hold the structure plus (n-1) extra elements of the array. In wine size is usually calculated with the macro FIELD_OFFSET(struct, member[size]).
Octavian
On Oct 12, 2011, at 1:31 PM, Octavian Voicu wrote:
On Wed, Oct 12, 2011 at 11:22 PM, Josh Juran josh@iswifter.net wrote:
My understanding is that accessing element n or greater in an array[n] is undefined behavior, but declaring a huge array and allocating only part of it is valid.
It's a commonly used pattern in C.
Agreed.
You declare a size-one array at the end of a structure, then you allocate enough memory to hold the structure plus (n-1) extra elements of the array. In wine size is usually calculated with the macro FIELD_OFFSET(struct, member[size]).
I understand. I'm just passing on what I read on another mailing list, which is that the construction is non-portable (even if it happens to work everywhere), and that might be the justification for the warning. A purist approach would call for avoiding this idiom, but pragmatically, disabling the warning is sufficient.
Josh
On 10/12/2011 02:29 PM, Jerome Leclanche wrote:
It would be nice to fix the "array subscript is above array bounds" warning spam for 1.4.0. They make up 90% of the warnings.
The fix would be to add a configure check for that bogus warning on access to the array[n]; n > 1 struct _tag { ... array[1]; }
and to add -Wno-array-bounds in that case.
bye michael