🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.msdos.programmer
Article #1281

Strange misoptimization in Turbo C

#1281
From: Paul Tomblin
Date: Mon, 19 Feb 1990 14:42
24 lines
1694 bytes
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)
Technical Details
Message-ID: <784@geovision.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!usc!jarthur!uunet!mitel!sce!cognos!geovision!pt

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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