>From https://gcc.gnu.org/gcc-6/porting_to.html, Narrowing conversions:
> The C++11 standard does not allow "narrowing conversions" inside braced
> initialization lists, meaning conversions to a type with less precision or a
> smaller range, for example:
>
> int i = 127;
> char s[] = { i, 256 };
>
> In the above example the value 127 would fit in char but because it's not a
> constant it is still a narrowing conversion. If the value 256 is larger than
> CHAR_MAX then that is also a narrowing conversion. Narrowing conversions can
> be avoided by using an explicit cast, e.g. (char)i.
I am wondering if the error messages aren't missleading and the culprits are
not the 0xFFs but the other stuff, therefore
> > const char structure_info[4] = { 0xFF, 0xFF, 0xFF, database_type };
const char structure_info[4] = { 0xFF, 0xFF, 0xFF, (char)database_type };
(if the cast is appropriate).
> > (trie_size >> 16) & 0xFF};
I have been fighting with MISRA-C checkers and would rewrite this at least as
(char)(((unsigned int)trie_size >> 16) & 0xFFU)};
maybe you also need 16U, (because 16 is int, therefore 'potentially negative'
in the opinion of stupid checkers 8-|
and 0xFFUL.
I hope this helps,
Peter Pöschl