Consider two objects with static storage duration and equal, constant initializers:
static const int a = 50;
static const int b = 50;
Is it valid for a compiler to combine these such that &a == &b
?
(For context, I was thinking of using static constant objects to get unique addresses to use as sentinel pointer values. If it is legal for a compiler to combine such objects and I use the same constant value for two such objects, then the addresses could be equal and I cannot use them as sentinel values.)
static
): Areconst
variables required to be distinct in memory? – Armrest