I think bitfields satisfy your conditions ... I believe fx is an lvalue, but you cannot take its address. Interestingly, you also cannot do auto & x = fx .
C ++ 11 Section 8.3.1 Part of paragraph 4: Since the address of the bit field (9.6) is not possible, the pointer can never point to a bit field.
struct foo { int x : 3; int y : 3; int z : 3; }; int main() { foo f; fx = 3; }
I'm even less sure about this other idea, but the standard says you are not allowed to use main function. If you use the address main, then this will also be sufficient. C ++ 11 3.6.1 Clause 5.
And from the comment I left, I know that TI extends its C and C ++ compilers, so there is a cregister storage class that you cannot take to address. (Because this refers to a physical register that does not have an address concept).
source share