New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-Wgnu-variable-sized-type-not-at-end in include/uapi/linux/bcache.h #1065
Comments
Reproducible with: $ make LLVM=1 LLVM_IAS=1 -j72 allyesconfig
$ make LLVM=1 LLVM_IAS=1 -j72 -s usr/include/ The members Looks like they were added to include/uapi/linux/bcache.h in MAINTAINERS has an entry for BCACHE. Though, I wonder if
|
On 4/28/21 16:06, Nick Desaulniers wrote:
Reproducible with:
```sh
$ make LLVM=1 LLVM_IAS=1 -j72 allyesconfig
$ make LLVM=1 LLVM_IAS=1 -j72 -s usr/include/
```
The members `uuid_bucket` and `btree_root` of `struct jset` seem to trigger this.
Looks like they were added to include/uapi/linux/bcache.h in
commit 81ab419 ("bcache: Pull on disk data structures out into a separate header")
MAINTAINERS has an entry for BCACHE.
Though, I wonder if `-Wgnu-variable-sized-type-not-at-end` should be moved under `-Wpedantic`? In fact, GCC does warn for this case with `-std=c90`, but only when `-Wpedantic` is enabled: https://godbolt.org/z/P8ejn81PW
```
<source>:7:17: warning: invalid use of structure with flexible array member [-Wpedantic]
7 | struct bkey key;
| ^~~
```
It seems to me that the problem here is the union containing an object
of a struct type that contains a flexible array:
#define BKEY_PADDED(key) \
union { struct bkey key; __u64 key ## _pad[BKEY_PAD]; }
…--
Gustavo
|
I think the solution might well be something like this: https://git.kernel.org/linus/c0a744dcaa29e9537e8607ae9c965ad936124a4d |
I see there is open-coded use of
I was going to say, "I'm surprised GCC doesn't warn about this issue already."
This does seem like the right approach here -- otherwise we'll have a standing warning difference between GCC and Clang otherwise. |
I wonder if we should just move some or all of bcache.h out of the uapi headers, this looks like it's not even meant to be done in user space, but it's hard to tell. |
This isn't CONFIG_WERROR related because that config doesn't set -Werror for HOSTCFLAGS. |
After llvm/llvm-project@113b0d7:
We do not see this type of warning in regular files due to
-Wno-gnu
being added toKBUILD_CFLAGS
but the header test uses a much smaller set of flags for build tests: https://elixir.bootlin.com/linux/v5.7.2/source/usr/include/MakefileI think this is legitimate though...
https://elixir.bootlin.com/linux/v5.7.2/source/include/uapi/linux/bcache.h
Slightly simplified: https://godbolt.org/z/j2Xwvf
Not quite sure how to fix it though since this structure already has a union at the end with zero-length arrays (and flexible members aren't allowed in unions?).
cc @kees @GustavoARSilva
The text was updated successfully, but these errors were encountered: