Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!ucsd!usc!cs.utexas.edu!rutgers!orstcs!jacobs.cs.orst.edu!keffert From: keffert@jacobs.cs.orst.edu (Thomas Keffer) Newsgroups: comp.lang.c++ Subject: Does "const" mean "const"?? Message-ID: <19078@orstcs.CS.ORST.EDU> Date: 26 Jun 90 23:33:22 GMT Sender: usenet@orstcs.CS.ORST.EDU Reply-To: keffert@jacobs.cs.orst.edu (Thomas Keffer) Organization: Oregon State University - CS - Corvallis Oregon Lines: 27 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