Re: [iptables PATCH] libiptc: Avoid gcc-10 zero-length array warning

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

 



Hi Jan,

On Thu, Oct 08, 2020 at 04:33:04PM +0200, Jan Engelhardt wrote:
[...]
> Anyway, gcc-10/C mode does not reject embedding (and a number of maintainers
> have made it abundantly clear in the past they don't care if UAPI uses anti-C++
> "features"). Nonreject example:
> 
> » cat x.c
> struct a2 {
>         int x;
>         int z[];
> };
> struct m {
>         struct a2 y;
>         long q;
> };
> » gcc -Wall -std=c11 -c -w -v x.c
> GNU C11 (SUSE Linux) version 10.2.1 20200825 [revision c0746a1beb1ba073c7981eb09f55b3d993b32e5c] (x86_64-suse-linux)

No need to pass '-w', gcc seems to accept the above unless one passes
'-pedantic' and thereby enables strict ISO C mode:

| % gcc -Wall -pedantic -std=c11 -c x.c   
| x.c:6:19: warning: invalid use of structure with flexible array member [-Wpedantic]
|     6 |         struct a2 y;
|       |                   ^

While the question of whether kernel UAPI headers should adhere to
strict ISO C or not may be debatable, my motivation for working around
the situation in user space comes from Gustavo's complaints when I tried
to convert the relevant struct members into flexible arrays. He
apparently is a burnt child looking at commit 1e6e9d0f4859e ("uapi:
revert flexible-array conversions").

Cheers, Phil



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux