On 25/02/2026 2:34 pm, Jan Beulich wrote:
> On 25.02.2026 13:59, Andrew Cooper wrote:
>> This was never because of a bug in GCC.
>>
>> C requires that static objects are initialised with constant expressions;
>> _mfn(), as a static inline, is not and cannot be made to be.
> Of course, and I think the comments were meant differently. What wasn't 
> possible
> to use (with -std=gnu99) due to the referenced bug is apparently
>
> #define INVALID_GFN ((gfn_t){ ~0UL })
>
> Now that gcc5 is our baseline, do we perhaps want to use that and do away with
> INVALID_GFN_INITIALIZER?

Oh.  Yeah that's very much not what the comment suggested.

Changing like that almost works, but there's one snag.  common/memory.c has

    BUILD_BUG_ON(INVALID_GFN_RAW + 1);

and with the _RAW constant wanting to go, the obvious:

    BUILD_BUG_ON(gfn_x(INVALID_GFN) + 1);

doesn't compile as it's no longer a constant expression.

It's not clear what to do here.  I don't think we want to keep
INVALID_GFN_RAW around for just this, but nor am I completely happy
dropping the BUILD_BUG_ON() either.

Thoughts?

~Andrew

Reply via email to