SUMMARY: difference in output.

From: unix doubts <unix_doubts_at_yahoo.com>
Date: Wed, 16 May 2001 01:32:57 -0700 (PDT)

Hi,

     Thanks to all who shared their thoughts on this.

I can summarize as below.

The reason this program fails on VMS but works on UNIX
is because the "initialdata" string constant gets put
into a read-only section on VMS and a read-write
section on UNIX in the object file.

There are too many UNIX programs which expect to be
able to write into string constants, so we must keep
the default the way it is.

We can use the -readonly_strings compile flag to tell
the compiler to put the string constant into a
read-only section. If you do that, your program will
crash, as expected.

Cheers and thanks to all again.

/svp.

> unix doubts writes:
> > Hi Experts,
> >
> > I don't know whether this is relevant place
> to
> > ask this question or not. I am sorry if I am
> wrong.
> >
> > main()
> > {
> > char *g="initialdata";
> > strcpy(g,"new");
> > printf("The string is %s",g);
> > }
> >
> > Why does this program crash in VMS and but not on
> > Tru64?
> >
> > where comes the difference between these two?
> >
> > thank you all.
> >
> > /svp



__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
Received on Wed May 16 2001 - 08:33:53 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:42 NZDT