string sharing (possible bug?)

Adam Bridge abridge at
Thu Dec 10 02:17:31 UTC 1998

On 12/9/98 at 5:48 PM, tod.blanchard at (Blanchard, Tod) wrote:

> In practice most C compilers are lax about checking for this and don't
> produce more than a single read/write data segment.  For instance, I just
> tried that program on Solaris using gcc and it worked exactly as I expected.
> Not even a warning. Most good C++ compilers generate a warning at
> initialization warning that a non-const pointer was initialized pointing to
> a const object but then C++ is more strict and you can circumvent that check
> with a cast anyhow.
> This is a common (albeit little known) problem in most languages and its
> simply up to the programmer to not modify string literals.

Hmmmm.....makes me think this is a generic problem with operating system design
in addition to a language problem.  Thinking back to my old DIGITAL days I
remember that it was possible to define PSECTS (Program sections) which were RO
(read only).  Attempting to write to an RO PSECT would cause a memory management
exception (here I'm thinking of VAX/VMS or RSX-11/M and maybe RT-11).

Now I don't know beans about UNIX and it's memory handling - but the micro
computer operating systems hardly do the right thing with these issue -- at
least not to my knowledge and it's really an operating system issue since
efficient useof the memory management hardware is what really makes this work


More information about the Squeak-dev mailing list