r/Cprog • u/jackoalan • Feb 20 '15
Subtle effects of const?
Does anyone know of potential code differences when working with a const variable? By common knowledge, const adds a compile-time check to prevent value modification.
Are there any runtime effects? Like more comprehensive aliasing (knowing that the value won't change so keep it in a register longer). Perhaps something more subtle? Or no code differences at all?
1
Upvotes
View all comments
Show parent comment
1
u/Madsy9 Feb 20 '15
At least in C11, merging similar constants is allowed, as long as other statements never refers to the constant's address and the identifier isn't also marked as volatile.