A classical discrepency between the GCC and G++ compilers. With godbolt.org, I noticed that this code (@brucehoult) will compile in GCC8.x and up, but not on older versions. On the other hand, it works in even the oldest G++ compilers.
However.. before GCC8.x flows downstream to IDE packages, you probably have to wait half a dozen years.
And I wouldn't recommended switching over a whole project to G++ because of this. That compiler is a bit stricter and your project may not compile (properly - under optimizations) elsewhere.
I would recommended replacing the "constants" with a macro in this case.
Well it isn't much a discrepancy between gcc and g++ as between C and C++.
C requires that all global variable initializers be expressions of literals. A variable, even a "const" variable is not allowed in the initializer expression. In principle, the language could be changed to allow "const" varaibles whose value is known, but this is not the case. Note: you can have a "const" variable whose value is not known at compile time. For instance, it could be "extern" (defined in a different source file), volatile (changeable by an external event), or forward declared with the value occurring later in the file.
This is one reason (of many) that despite the problems with #define macros it is most common to use #define for compile time constants, especially when you need multiple constants derived from each other.
C++ on the other hand lets you initialize global variables with almost anything you want including runtime computation. This is handled by linker magic. For instance, on ELF systems, every object file has a ".init" section. Initializer code is placed in there and the linker makes sure that all code in .init sections gets called before main().
Note that this has "interesting" behavior too. The order of initializers in different translation units is undefined, so initializing a variable from an "extern" variable is pretty much always wrong. Furthermore, within a translation unit, the order of initialization depends on whether variables are const or not, *and* whether their initializer is a compile time constant.