cbp@foster.avid.oz (Cameron Paine) (10/11/90)
I'm porting some code to an ANSI-conforming compiler and have encountered an anomaly which my reading of K&R(2) and H&S(2) hasn't resolved. In the original code, I used many expressions (the reason for doing this is not relevant) such as: char *cptr; cptr = "XYhello, world!" + 2; which has traditionally rendered: *cptr == 'h' /* because cptr => "hello, world!" */ Under the ANSI-conforming compiler, I find that: *cptr == 'X' /* because cptr => "XYhello, world!" */ Experimentation has revealed that: cptr = "XYhello, world!"; cptr += 2; achieves the result I'm after but this is of little use to me. The question then is whether the new compiler's behaviour is correct. The documentation I have implies that it isn't but I'd like to hear what the lawyers think. Thanks. Cameron -- cbp@foster.avid.oz - ACSnet cbp@foster.avid.oz.au - Internet ...!{hplabs,mcvax,nttlab,ukc,uunet}!munnari!foster.avid.oz.au!cbp - UUCP
cbp@foster.avid.oz (Cameron Paine) (10/12/90)
In <1990Oct11.064854.12867@foster.avid.oz> I wrote: >I'm porting some code to an ANSI-conforming compiler and have encountered >an anomaly which my reading of K&R(2) and H&S(2) hasn't resolved... Email respondents have unequivocally indicated that the compiler is broken. Thanks to Doug Gwyn, Bill Wells and Steve Clamage (and any others who's mail I've yet to receive -- it takes a while to get Down Under). I guess it's time to file YACB report. Cameron -- cbp@foster.avid.oz - ACSnet cbp@foster.avid.oz.au - Internet ...!{hplabs,mcvax,nttlab,ukc,uunet}!munnari!foster.avid.oz.au!cbp - UUCP