[gnu.gcc.bug] xclock and "gcc -O" don't mix

ado@ALW.NIH.GOV (Arthur David Olson) (10/08/89)

			  X Window System Bug Report
			    xbugs@expo.lcs.mit.edu




VERSION:
	R3

CLIENT MACHINE and OPERATING SYSTEM:
	Sun 3/60 running SunOS 4.0.3

DISPLAY:
	Sun CG4

WINDOW MANAGER:
	uwm

AREA:
	xclock

SYNOPSIS:
	xclock and gcc -O don't mix

DESCRIPTION:
	xclock.c contains this code. . .
		static Junk()
		{
		#include <X11/Vendor.h>
		WidgetClass junk = vendorShellWidgetClass;
		}
	. . .to create a reference to "vendorShellWidgetClass" in "xclock.o"
	and cause "the linker to include the vendorShell module from Xaw,
	rather than the one from Xt".  As it happens, gcc optimization is
	smart enough to notice that "junk" is never used; it therefore doesn't
	generate the desired reference.  So the Xaw vendorSehllWidgetClass
	doesn't get included; in particular, this means that iconPixmaps
	can't be set for xclocks.

REPEAT BY:
	Compiling xclock using gcc and the -O option, then using the command
		xclock -xrm "*iconPixmap: mensetmanus"
	and noting the
		X Toolkit Warning: No type converter registered for
			'String' to 'Pixmap' conversion.
	warning.

SAMPLE FIX:
*** 1.1/xclock.c	Sat Oct  7 16:44:21 1989
--- 1.2/xclock.c	Sat Oct  7 16:44:21 1989
***************
*** 52,61 ****
  /* this silliness causes the linker to include the VendorShell
   * module from Xaw, rather than the one from Xt.
   */
! static Junk()
  {
  #include <X11/Vendor.h>
! WidgetClass junk = vendorShellWidgetClass;
  }
  #endif
  
--- 52,61 ----
  /* this silliness causes the linker to include the VendorShell
   * module from Xaw, rather than the one from Xt.
   */
! static WidgetClass Junk()
  {
  #include <X11/Vendor.h>
!     return vendorShellWidgetClass;
  }
  #endif
  
-- 
	 To understand Sun's corporate culture look at the vi source code.
	Arthur David Olson   ado@alw.nih.gov   ADO is a trademark of Ampex.