From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10f8a1,bda6136a6fefc8c6,start X-Google-Attributes: gid10f8a1,public X-Google-Thread: 1164f8,bda6136a6fefc8c6,start X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1993-03-27 12:47:44 PST Xref: sparky vmsnet.alpha:377 comp.sys.dec:8102 Newsgroups: vmsnet.alpha,comp.sys.dec Path: sparky!uunet!math.fu-berlin.de!aa.cad.slb.com!aa.cad.slb.com!dsmith From: dsmith@ann-arbor.applicon.slb.com (J. Daniel Smith) Subject: Might this be a VMS or C problem on the AXP? Organization: Applicon, Inc.; Ann Arbor, MI (USA) Date: Sat, 27 Mar 1993 20:47:44 GMT Message-ID: The follwoing short program produces "correct" resusts on the DECstation, VAX/VMS, and HP boxes, but fails with a SEGV on the AXP/VMS when an attempt is made to change the value of the string literal. ----- #include int main(void) { char *c = "x"; c[0] = 'x'; c[1] = '\0'; printf("c = \"%s\"\n", c); c[0] = 'y'; printf("c = \"%s\"\n", c); } ----- According to the ANSI spec, "If a program attempts to modify a string literal..., the behavior is undefined". (Section 3.1.4) so, strickly speaking, I guess this can't be considered a bug. Still, it is a bit surprising to me that it does get detected and cause a failure on the AXP/VMS, especially since it does not crash under VAX/VMS. Can someone explain excatly what is happening on the AXP/VMS? Is there a way to make this program crash under VAX/VMS (or other platforms)? Thanks, Dan -- ==== message is author's opinion only -- it is not an official statement ==== J. Daniel Smith dsmith@ann-arbor.applicon.slb.com Applicon, Inc. dsmith@aaaca1.sinet.slb.com Ann Arbor, Michigan (USA) AAACA1::DSMITH (SINet)