From 05e4993d2e9664ca1025172148007ff32e30fa57 Mon Sep 17 00:00:00 2001 From: Piotr Tworek Date: Tue, 5 Oct 2021 15:35:12 +0200 Subject: [PATCH] gems: Avoid flexible array member in Cached_font. Switch the code to 0 lengh array instead. The code in Lru_cache::element_size calls sizeof on this structure. This works in gcc, but fails when using clang. Even for GCC however the documentation states: "Flexible array members have incomplete type, and so the sizeof operator may not be applied. As a quirk of the original implementation of zero-length arrays, sizeof evaluates to zero." Basically its an implementation quirk that clang does not support. Both GCC and clang do support zero sized arrays however so using them here allows both compilers to process this code. Ref: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html Issue #4421 --- repos/gems/include/gems/cached_font.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repos/gems/include/gems/cached_font.h b/repos/gems/include/gems/cached_font.h index 72679634be..439e822b90 100644 --- a/repos/gems/include/gems/cached_font.h +++ b/repos/gems/include/gems/cached_font.h @@ -30,7 +30,7 @@ class Genode::Cached_font : public Text_painter::Font struct Cached_glyph : Glyph, Noncopyable { - Glyph::Opacity _values[]; + Glyph::Opacity _values[0]; /* * The number of values is not statically known but runtime-