Xref: utzoo alt.msdos.programmer:1294 comp.sys.ibm.pc:45049 Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!usc!jarthur!uunet!mitel!sce!cognos!geovision!pt From: pt@geovision.uucp (Paul Tomblin) Newsgroups: alt.msdos.programmer,comp.sys.ibm.pc Subject: Strange misoptimization in Turbo C Message-ID: <784@geovision.UUCP> Date: 19 Feb 90 14:42:24 GMT Reply-To: pt@geovision.UUCP (Paul Tomblin) Organization: GeoVision Corp, Ottawa, Canada Lines: 24 Has anybody seen this? Has Borland? Anybody know why it occurs? I've just received CXL5.1, and was recompiling the demo program with Turbo C 2.0 (with all the patches, I think), and was getting some pretty strange behaviour. In the menuing demo, after choosing one of the options that toggles yes to no, I got a screen full of garbage, and many errors later on because the string space seemed a little corrupt. Investigation showed that the culprit was the following line: strcpy(yn,strcmp(yn,"yes")?"yes":" no"); in toggle_yn(). The temporary pointer that should have been pointing to the string " no", was instead pointing into the middle of some other very long string. I tried turning off the questionable optimizations like -Z and even -O, but to no avail. It did work, however, if I turned off the "merge duplicate strings" (-d) option. I really like the idea of this option, since it can make quite a difference, so I'd like to know if there is a patch to fix this. I've never seen this problem before in any other code I've compiled. -- Paul Tomblin nrcaer!cognos!geovision!pt or uunet!geovision!pt Life: Loath it or ignore it, you can't like it. (Marvin) (My employer may not agree with my opinions, especially my .signature)