tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* SUMMARY: difference in output.
@ 2001-05-16  8:32 unix doubts
  0 siblings, 0 replies; only message in thread
From: unix doubts @ 2001-05-16  8:32 UTC (permalink / raw)
  To: tru64-unix-managers

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/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-05-16  8:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-05-16  8:32 SUMMARY: difference in output unix doubts

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