Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!lll-winken!gauss.llnl.gov!casey From: casey@gauss.llnl.gov (Casey Leedom) Newsgroups: comp.windows.x Subject: Re: warning about gcc 1.36 (on 680x0 only?) Message-ID: <43810@lll-winken.LLNL.GOV> Date: 10 Jan 90 01:27:10 GMT References: <9001081420.AA00672@expire.lcs.mit.edu> Sender: usenet@lll-winken.LLNL.GOV Reply-To: casey@gauss.llnl.gov.UUCP (Casey Leedom) Organization: Lawrence Livermore National Laboratory Lines: 50 | From: rws@EXPO.LCS.MIT.EDU (Bob Scheifler) | From a bug report: | | Versions 1.34 and 1.36 of GCC incorrectly compile the expression | ``"..." == 0 ? exp1 : exp2'' into "exp1". | | This expression is used by XtNewString (in lib/Xt/Intrinsic.h). It turns out there's a simple work around for this. The problem only appears to be with respect to equality comparisons between constant strings and 0 in the ternary operator "?:". Inequality comparisons seem to work fine. Thus, if you change the definition of the XtNewString macro as follows: *** mit/lib/Xt/Intrinsic.h-dist Fri Dec 15 04:35:00 1989 --- mit/lib/Xt/Intrinsic.h Sun Jan 7 20:43:15 1990 *************** *** 2144,2150 **** #define XtNew(type) ((type *) XtMalloc((unsigned) sizeof(type))) #define XtNewString(str) \ ! ((str) == NULL ? NULL : (strcpy(XtMalloc((unsigned)strlen(str) + 1), str))) extern char *XtMalloc( #if NeedFunctionPrototypes --- 2144,2150 ---- #define XtNew(type) ((type *) XtMalloc((unsigned) sizeof(type))) #define XtNewString(str) \ ! ((str) != NULL ? (strcpy(XtMalloc((unsigned)strlen(str) + 1), str)) : NULL) extern char *XtMalloc( #if NeedFunctionPrototypes and then recompile the following files: ./lib/Xmu/CvtStdSel.c:105: return XtNewString("SunOS"); ./lib/Xmu/CvtStdSel.c:108: return XtNewString("BSD"); ./clients/xmh/toc.c:902: argv[0] = XtNewString("rmm"); ./clients/xmh/toc.c:909: argv[0] = XtNewString("refile"); ./clients/xmh/toc.c:942: argv[cur++] = XtNewString("-src"); ./clients/xmh/tocutil.c:270: seq->name = XtNewString("all"); everything should work ... Note that Richard Stallman tells me that the current BETA version of GCC 1.37 doesn't have this problem. Richard mumbled something about ``soon'' with respect to a release date but didn't get any more specific. Casey