Read-only Strings
Chris Torek
chris at umcp-cs.UUCP
Sat Nov 3 14:06:52 AEST 1984
Another good(?) reason for readonly strings is that then the compiler
could use the same address for "equal" strings; that is, if I write
printf("%d\n", x);
.
.
.
printf("%d\n", y);
the compiler might produce
.data
L21: .asciz "%d\n"
.text
pushl x # well not really but...
pushal L21
calls $2,printf
.
.
.
pushl y
pushal L21
calls $2,printf
Many FORTRAN compilers use similar tricks when passing constants to
subroutines or functions... I think I once used the "modify-the-constant"
trick to change the WRITE unit number, just for fun.
--
(This mind accidently left blank.)
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (301) 454-7690
UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet: chris at umcp-cs ARPA: chris at maryland
More information about the Comp.lang.c
mailing list