]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libasm: Fix xdefault_pattern initialization
authorIlya Leoshkevich <iii@linux.ibm.com>
Wed, 8 Feb 2023 19:52:20 +0000 (20:52 +0100)
committerMark Wielaard <mark@klomp.org>
Thu, 9 Feb 2023 13:12:21 +0000 (14:12 +0100)
commit61b99b89f5419cf5be6dd3350ad0b01caabc7447
treea86afec5000798a9b9f032aa24f8f3057d9c82af
parentccd619eb5cf5e065173557176ba84f17bd341e5e
libasm: Fix xdefault_pattern initialization

clang complains:

    asm_newscn.c:48:22: error: field 'pattern' with variable sized type 'struct FillPattern' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end]
      struct FillPattern pattern;
                         ^

Fix by using a union instead. Define the second union member to be a
char array 1 byte larger than struct FillPattern. This should be legal
according to 6.7.9:

    If an object that has static or thread storage duration is not
    initialized explicitly, then ... if it is a union, the first named
    member is initialized (recursively) according to these rules, and
    any padding is initialized to zero bits.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
libasm/asm_newscn.c