Paul Brook wrote: > Contrary to popular belief the "const" qualifier on pointers has > absolutely no effect on optimization. It's simply a debugging aid so > the compiler will generate an error if you accidentally assign to > it.
That's only true when the "const" applies to pointer targets, as in: const char * ptr = "foo"; It does not apply when the "const" applies to the pointer itself. This puts the pointer "ptr" into RO storage: const char * const ptr = "foo"; Hence the large number of times that pattern occurs in the patch. > It's perfectly legal to cast a (const char *) to a (char *) then > dereference and write to it, provided the object the object it ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > points to is modifiable. ^^^^^^^^^^^^^^^^^^^^^^^ Precisely. Global and static variables that are declared "const" are not "modifiable", and are put in RO storage, so they cannot be written to. Taking their address creates a "const" pointer which must not be derefenced and written to. -- Jamie _______________________________________________ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel