🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #1743

VMS C compiler bug (addles Emacs' redisplay)

#1743
From: Dave Gentzel
Date: Sun, 04 Jun 1989 06:28
90 lines
2726 bytes
I've uncovered a major bug in version 3.0 of DEC's VAX C compiler for VMS.
This bug showed up compiling GNU Emacs.  (Emacs users take note.  You should
compile DISPNEW.C with /OPTIMIZE=NOINLINE so long as this bug exists.  There
may be other files which tickle the bug, but this is the only one I noticed.
The symptom is that redisplays become strangely and decidedly non-optimal!)

Basically, the compiler messes up some references to the arguments of inlined
functions.  Here is a file which tickles the bug along with an annotated
assembler listing showing the problem.  Yet another reason to use GCC, I
suppose...

					David Gentzel
					Pittsburgh Supercomputing Center
					gentzel@cpwsca.psc.edu
					or gentzel@morgul.psc.edu

P.S. I haven't submitted an SPR on this.  Any takers?

------------------------------ bug.c ------------------------------
int count_blanks(char *str)
{
    char *p = str;

    while (*str++ == ' ');
    return str - p - 1;
}

int bug(char *s)
{
    return count_blanks(s);
}
------------------------------ tst.c ------------------------------
#include <stdio.h>

main()
{
    char test[] = "    ";

    printf("right: %d\ncount_blanks: %d\nbug: %d\n",
	   sizeof test - 1, count_blanks(test), bug(test));
}
-------------------------------------------------------------------
int count_blanks(char *str)
{
				count_blanks:
				    .entry	count_blanks,^m<>
				    subl2	#4,sp
    register char *p = str;
				    movl	4(ap),r1

    while (*str++ == ' ');
				    incl	4(ap)
				    cmpb	(r1),#32
				    bneq	sym.2
				    tstl	r0
				    nop	
				sym.1:
				    movl	4(ap),r0
				    incl	4(ap)
				    cmpb	(r0),#32
				    beql	sym.1
				sym.2:
    return str - p - 1;
				    subl3	r1,4(ap),r0
				    decl	r0
				    ret	
}

int bug(register char *s)
{
				bug:
				    .entry	bug,^m<r2>
				    subl2	#4,sp
    return count_blanks(s);
				    movl	4(ap),r1
				    cmpb	(r1)+,#32
				    bneq	sym.4
				    tstl	r0
				sym.3:
				    cmpb	(r1)+,#32
				    beql	sym.3
				sym.4:
				    subl3	r1,r1,r2    <--- BUG HERE
							         should be
							    subl3 r1,4(ap),r2
				    decl	r2
				    movl	r2,r0
				    ret	
}
-------------------------------------------------------------------
Technical Details
Message-ID: <890604022822.20e08c69@B.PSC.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!CPWSCB.PSC.EDU!GENTZEL

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!CPWSCB.PSC.EDU!GENTZEL
From: GENTZEL@CPWSCB.PSC.EDU (Dave Gentzel)
Newsgroups: gnu.emacs.bug
Subject: VMS C compiler bug (addles Emacs' redisplay)
Message-ID: <890604022822.20e08c69@B.PSC.EDU>
Date: 4 Jun 89 06:28:22 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 90