Re: Need C optimization help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Please forgive me for potentially silly question that may not help Mark speedup his program. If I understand the "const" keyword, it tells the
computer that after a const variable gets its first value, that
variable's value will be unchangeable. So I wonder why our friend has declared some const variables inside a for-loop and why those variables
appear on the left sides of the assignment operator inside that loop.
Silly question: Could Mark's computer be wasting time by trying to
change the value of a variable that already has an unchangeable value?


No, const simply asks the compiler to notify you when you write code which changes the value.

Modifying an object via a const lvalue is a constraint violation; any
program that does this is not a valid C program.

Modifying a const object via a non-const lvalue is undefined behaviour.


Segher


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux