Besides invoking "undefined behavior" by using casts to circumvent the compiler's checks to change the value of a const
variable, the observed result can be explained with the optimizations the compiler likely did:
In the first case, you declare a const array, which likely ends up as data somewhere in RAM.
In the second case, you have a single scalar const value and the compiler probably decided to just use the constant's value which is known at compile time in the output instead of reading that known value from a RAM location. This optimization is also known as constant propagation.
If you didn't take the address of a
in your code, it's value would probably not even have a location in data RAM allocated.