keffert@jacobs.cs.orst.edu (Thomas Keffer) (06/27/90)
Consider the following:
void foo(const int* j)
{
*(int*)j = 5; // Ignore the "constness" of j
}
main()
{
i = 0;
foo(&i);
printf("i = %d\n"); // What's the value of i?
}
The question is: Can an aggressive optimizing compiler assume that
a variable passed to a function as a const pointer will remain
unchanged after invokation of the function? Or, if you prefer
a more philosophical pitch: is "const" a documentation aid, or
a hint to the compiler?
-tk
___
Thomas Keffer
Rogue Wave Assoc.
P.O. Box 2328
Corvallis, OR 97339
(503) 745-5908