flee@shire.cs.psu.edu (Felix Lee) (07/21/89)
Machine Type: Sun 4/260S O/S Version: SunOS 4.0 Organization: Computer Science Department, The Pennsylvania State University 333 Whitmore Laboratory, University Park, PA 16802 Phone Number: +1 814 865 9723 Description: The Sun-4 C compiler incorrectly optimizes the function XtInstallAccelerators() in the file TMstate.c in the Xt library in X11 release 3. Repeat-By: Compile the file with -O and examine the assembly. Notice that it calls XtInitializeStateTable() immediately after calling _XtBindAccActions(), which by no stretch of the imagination can be considered a correct optimization. Relevant code section follows. For complete source, grab the latest X distribution from a random archive/distribution site. void XtInstallAccelerators(destination,source) Widget destination,source; { XtBoundAccActions accBindings; if ((!XtIsWindowObject(source)) || source->core.accelerators == NULL) return; /* if (source->core.accelerators->accProcTbl == NULL) * %%% * The spec is not clear on when actions specified in accelerators are bound; * The most useful (and easiest) thing seems to be to bind them at this time * (rather than at Realize). Under the current code the preceeding test * seems always to be True, thus guaranteeing accBindings is always set * before being used below. */ _XtBindAccActions(source,source->core.accelerators,0,&accBindings); if (destination->core.tm.translations == NULL) { destination->core.tm.translations = source->core.accelerators; destination->core.tm.translations->accProcTbl = accBindings; } else { XtTranslations temp; _XtInitializeStateTable(&temp); temp->clickTime = source->core.accelerators->clickTime; if (source->core.accelerators->operation == XtTableOverride) { MergeTables(temp,source->core.accelerators,FALSE,accBindings); MergeTables(temp, destination->core.tm.translations,FALSE, destination->core.tm.translations->accProcTbl); } else { MergeTables(temp, destination->core.tm.translations,FALSE, destination->core.tm.translations->accProcTbl); MergeTables(temp,source->core.accelerators,FALSE,accBindings); } destination->core.tm.translations = temp; } [... etc. ] [copyright notice for the above:] /*********************************************************** Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the names of Digital or MIT not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ -- Felix Lee flee@shire.cs.psu.edu *!psuvax1!shire!flee