🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2832

GCC bitfield optimization bug

#2832
From: mike
Date: Fri, 12 Jan 1990 22:58
71 lines
2736 bytes
The following routine will cause GCC(1.36) to seg fault
when compiled with '-O'.

                struct csr {
                                char  x;
                                unsigned int   y : 1;
                } *csr;
                
                tst()
                {
                        do {
                                if (csr->x & 1)
                                        foo();
                        } while (csr->y);
                }
                
on another note, here is a suggested bug fix for another problem :

        volatile struct  x { int y : 24; } *z;
        
        main()
        {
                tst(z->y);
        }

This causes the compiler to abort() ???


*** expmed.c.ORIG	Tue Sep 12 15:46:21 1989
--- expmed.c	Thu Nov  2 16:25:38 1989
***************
*** 708,714 ****
  	  /* If op0 is a register, we need it in SImode
  	     to make it acceptable to the format of extzv.  */
  	  if (GET_CODE (xop0) == SUBREG && GET_MODE (xop0) != SImode)
! 	    abort ();
  	  if (GET_CODE (xop0) == REG && GET_MODE (xop0) != SImode)
  	    xop0 = gen_rtx (SUBREG, SImode, xop0, 0);
  
--- 708,714 ----
  	  /* If op0 is a register, we need it in SImode
  	     to make it acceptable to the format of extzv.  */
  	  if (GET_CODE (xop0) == SUBREG && GET_MODE (xop0) != SImode)
! 	    xop0 = convert_to_mode (SImode, xop0, 1);
  	  if (GET_CODE (xop0) == REG && GET_MODE (xop0) != SImode)
  	    xop0 = gen_rtx (SUBREG, SImode, xop0, 0);
  
***************
*** 818,824 ****
  	  /* If op0 is a register, we need it in SImode
  	     to make it acceptable to the format of extv.  */
  	  if (GET_CODE (xop0) == SUBREG && GET_MODE (xop0) != SImode)
! 	    abort ();
  	  if (GET_CODE (xop0) == REG && GET_MODE (xop0) != SImode)
  	    xop0 = gen_rtx (SUBREG, SImode, xop0, 0);
  
--- 818,824 ----
  	  /* If op0 is a register, we need it in SImode
  	     to make it acceptable to the format of extv.  */
  	  if (GET_CODE (xop0) == SUBREG && GET_MODE (xop0) != SImode)
! 	    xop0 = convert_to_mode (SImode, xop0, 0);
  	  if (GET_CODE (xop0) == REG && GET_MODE (xop0) != SImode)
  	    xop0 = gen_rtx (SUBREG, SImode, xop0, 0);

-------

Kudos to Rob Stanzel (rps@apollo.hp.com) for this one.

Mike Schloss
mike@apollo.hp.com
508-256-6600 x-6751
Technical Details
Message-ID: <9001122250.AA25109@xuucp.ch.apollo.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!APOLLO.COM!mike

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!APOLLO.COM!mike
From: mike@APOLLO.COM
Newsgroups: gnu.gcc.bug
Subject: GCC bitfield optimization bug
Message-ID: <9001122250.AA25109@xuucp.ch.apollo.com>
Date: 12 Jan 90 22:58:38 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 71