svn commit: r186529 - head/sys/dev/acpi_support
Christoph Mallon
christoph.mallon at gmx.de
Thu Jan 1 09:39:25 UTC 2009
Joerg Sonnenberger schrieb:
> On Sun, Dec 28, 2008 at 10:00:37PM +0100, Dimitry Andric wrote:
>> On 2008-12-28 20:30, Stanislav Sedov wrote:
>>>>> - ACPI_OBJECT acpiarg[0];
>>>>> + ACPI_OBJECT acpiarg[1];
>>> I wonder how does gcc allowed this. It emits warnings only in
>>> pedantic mode which we cannot use to compile kernel with.
>> Zero-sized arrays are non-standard, but have been allowed by gcc (and
>> many other compilers) since a long time, so it is logical that it
>> doesn't warn about it by default.
>
> Having no size at all would be standard compliant, e.g. acpiarg[[];
No, it wouldn't be standard compliant. You are confusing this with a
flexible array member as last entry of a struct declaration (C99
§6.7.2.1:16). As an (old) extension GCC accepts [0] as flexible array
member, too.
The declaration here is a declaration of an array with automatic storage
duration and no linkage. Having nothing in the [] (and no initialiser)
would make the array an incomplete type (C99 §6.7.5.2:4), which is not
valid for a local variable (C99 §6.2.2:6 and §6.7:7). Also 0 as size
expression clearly violates the standard: "If the expression is a
constant expression, it shall have a value greater than zero." (C99
§6.7.5.2:1).
A local array with length 0 has no practical purpose either.
Regards
Christoph
More information about the svn-src-all
mailing list