tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: unix doubts <unix_doubts () yahoo ! com>
To: tru64-unix-managers
Subject: SUMMARY: difference in output.
Date: Wed, 16 May 2001 08:32:57 +0000	[thread overview]
Message-ID: <102653647621891.tru64-unix-managers.marc@archive.invalid> (raw)

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/

                 reply	other threads:[~2001-05-16  8:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox