On Tue, 29 May 2018, Richard Biener wrote: > The testcase dates back to some repository creation rev. (egcs?) and > I'm not sure we may compute the difference of addresses of structure > members. So that GCC accepts this is probably not required. Joseph > may have a definitive answer here.
My model of constant expressions for GNU C says this sort of subtraction (of two address constants based on the same object or function address) is a symbolic difference constant expression, which should be accepted as constant in initializers as an extension; it should be folded like other offsetof-like constructs. That should not depend on whether the result gets converted to a type of different width. However, the result of converting an address constant pointer to an integer type is only expected to be a constant expression if the resulting type *is* the same width as pointers. -- Joseph S. Myers jos...@codesourcery.com