No, according to the C standard, simply declaring a const
variable without ever using it does not cause undefined behavior.
The presence of an unused const
variable may lead to compiler warnings or the compiler optimizing it away, but the standard does not define this scenario as undefined behavior. It is purely a matter of optimization and static analysis, not correctness.
In short: Declaring an unused const
variable is allowed and safe; it will not trigger undefined behavior.