🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Russ Tuck Thu, 06 Jul 1989 20:00
bug evaluating "/"
#98
Author: Russ Tuck
Date: Thu, 06 Jul 1989 20:00
344 lines
9799 bytes
Return-Receipt-To: tuck@cs.unc.edu

Enclosed is a shar file.  The bug report is in the leading comment of the .c
file (tuck0.c), and includes my address.

Since I haven't found a work-around yet, I'd appreciate any advice, comments,
work-arounds or fix.

I appreciate all the good work that has gone into developing g++.

	Russ

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	tuck0.c
#	tuck0.s
#	tuck0.script
# This archive created: Thu Jul  6 15:55:49 1989
# By:	Russ Tuck ()
export PATH; PATH=/bin:$PATH
echo shar: extracting "'tuck0.c'" '(1627 characters)'
if test -f 'tuck0.c'
then
	echo shar: will not over-write existing file "'tuck0.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'tuck0.c'
 X/* G++ bug report.
 X   This is file "tuck0.c".
 X   Submitted by:
 X	Russ Tuck		               internet: tuck@cs.unc.edu
 X	Computer Science Dept., Sitterson Hall csnet:    tuck@unc
 X	University of North Carolina           uucp:     ...!mcnc!unc!tuck
 X	Chapel Hill, NC 27599-3175, USA        Phone: (919)962-1755 or 962-1932
 X   g++ version: 1.35.1-
 X   cpu: Sun-4/280 (sparc)
 X   os: SunOS Sys4-3.2
 X   date: 6 July 1989
 X   Summary:
 X     1) Particular expressions involving division (/) are sometimes evaluated
 X        incorrectly at run time.  (It appears to me that reg %o1 is not being
 X	set before calling .div; it sometimes happens to have the right value.)
 X     2) g++ -O tuck0.c gets "fatal signal 4" in cc1plus
 X	
 X   I have not found a work-around yet.
 X
 X   Enclosures:
 X     tuck0.s		-- assembler output from "g++ -g -S tuck0.c".
 X     tuck0.script	-- script showing compile and run of tuck0.c
 X*/
 X
 X#include <stdio.h>
 X
 Xmain()
 X{
 X  printf("(5 + 32) / 32 evaluates to %d.\n", (5 + 32) / 32);
 X  int ti = 32;
 X  printf("(5 + ti) / ti evaluates to %d.\n", (5 + ti) / ti);
 X  printf("(5 + ti) / ti evaluates to %d.\n", (5 + ti) / ti);
 X  unsigned tu = 32;
 X  printf("(5 + tu) / tu evaluates to %u.\n", (5 + tu) / tu);
 X  printf("(5 + tu) / tu evaluates to %u.\n", (5 + tu) / tu);
 X
 X  printf("37 / 32 evaluates to %d.\n", 37 / 32);
 X  printf("37 / tu evaluates to %u.\n", 37 / tu);
 X  printf("37 / tu evaluates to %u.\n", 37 / tu);
 X  printf("37 / ti evaluates to %d.\n", 37 / ti);
 X  printf("37 / ti evaluates to %d.\n", 37 / ti);
 X
 X  int ti0 = 32;
 X  int ti1 = 5 + ti0;
 X  int ti2 = ti1 / ti0;
 X  printf("ti0 = %d, ti1 = %d, ti2 = %d\n", ti0, ti1, ti2);
 X}
SHAR_EOF
if test 1627 -ne "`wc -c < 'tuck0.c'`"
then
	echo shar: error transmitting "'tuck0.c'" '(should have been 1627 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'tuck0.s'" '(3557 characters)'
if test -f 'tuck0.s'
then
	echo shar: will not over-write existing file "'tuck0.s'"
else
sed 's/^ X//' << \SHAR_EOF > 'tuck0.s'
 Xgcc_compiled.:
 X	.stabs "tuck0.c",100,0,0,Ltext
 XLtext:
 X.stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
 X.stabs "char:t2=r2;0;127;",128,0,0,0
 X.stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0
 X.stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
 X.stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0
 X.stabs "short int:t6=r1;-32768;32767;",128,0,0,0
 X.stabs "long long int:t7=r1;0;-1;",128,0,0,0
 X.stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
 X.stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0
 X.stabs "signed char:t10=r1;-128;127;",128,0,0,0
 X.stabs "unsigned char:t11=r1;0;255;",128,0,0,0
 X.stabs "float:t12=r1;4;0;",128,0,0,0
 X.stabs "double:t13=r1;8;0;",128,0,0,0
 X.stabs "long double:t14=r1;8;0;",128,0,0,0
 X.stabs "void:t15=15",128,0,0,0
 X.stabs "$vtbl_ptr_type:t16=s8delta:/26,0,16;index:/26,16,16;pfn:/217=*15,32,32;delta2:/26,32,16;;~;",128,0,0,0
 X.text
 XLC0:
 X	.ascii "(5 + 32) / 32 evaluates to %d.\12\0"
 XLC1:
 X	.ascii "(5 + ti) / ti evaluates to %d.\12\0"
 XLC2:
 X	.ascii "(5 + tu) / tu evaluates to %u.\12\0"
 XLC3:
 X	.ascii "37 / 32 evaluates to %d.\12\0"
 XLC4:
 X	.ascii "37 / tu evaluates to %u.\12\0"
 XLC5:
 X	.ascii "37 / ti evaluates to %d.\12\0"
 XLC6:
 X	.ascii "ti0 = %d, ti1 = %d, ti2 = %d\12\0"
 X	.align 4
 X.global _main
 X	.proc 1
 X_main:
 X.stabn 68,0,28,LM1
 XLM1:
 X	!#PROLOGUE# 0
 X	save %sp,-152,%sp
 X	!#PROLOGUE# 1
 XLBB2:
 X.stabn 68,0,29,LM2
 XLM2:
 X	sethi %hi(LC0),%o0
 X	or %lo(LC0),%o0,%o0
 X	mov 1,%o1
 X	call _printf,0
 X	nop
 X.stabn 68,0,30,LM3
 XLM3:
 X	mov 32,%o4
 X	st %o4,[%fp-20]
 X.stabn 68,0,31,LM4
 XLM4:
 X	ld [%fp-20],%o0
 X	add %o0,5,%o0
 X	call .div,0
 X	nop
 X	mov %o0,%o1
 X	sethi %hi(LC1),%o0
 X	or %lo(LC1),%o0,%o0
 X	mov %o1,%o1
 X	call _printf,0
 X	nop
 X.stabn 68,0,32,LM5
 XLM5:
 X	ld [%fp-20],%o0
 X	add %o0,5,%o0
 X	call .div,0
 X	nop
 X	mov %o0,%o1
 X	sethi %hi(LC1),%o0
 X	or %lo(LC1),%o0,%o0
 X	mov %o1,%o1
 X	call _printf,0
 X	nop
 X.stabn 68,0,33,LM6
 XLM6:
 X	mov 32,%o4
 X	st %o4,[%fp-28]
 X.stabn 68,0,34,LM7
 XLM7:
 X	ld [%fp-28],%o0
 X	add %o0,5,%o0
 X	call .udiv,0
 X	nop
 X	mov %o0,%o1
 X	sethi %hi(LC2),%o0
 X	or %lo(LC2),%o0,%o0
 X	mov %o1,%o1
 X	call _printf,0
 X	nop
 X.stabn 68,0,35,LM8
 XLM8:
 X	ld [%fp-28],%o0
 X	add %o0,5,%o0
 X	call .udiv,0
 X	nop
 X	mov %o0,%o1
 X	sethi %hi(LC2),%o0
 X	or %lo(LC2),%o0,%o0
 X	mov %o1,%o1
 X	call _printf,0
 X	nop
 X.stabn 68,0,37,LM9
 XLM9:
 X	sethi %hi(LC3),%o0
 X	or %lo(LC3),%o0,%o0
 X	mov 1,%o1
 X	call _printf,0
 X	nop
 X.stabn 68,0,38,LM10
 XLM10:
 X	call .udiv,0
 X	nop
 X	mov %o0,%o1
 X	sethi %hi(LC4),%o0
 X	or %lo(LC4),%o0,%o0
 X	mov %o1,%o1
 X	call _printf,0
 X	nop
 X.stabn 68,0,39,LM11
 XLM11:
 X	call .udiv,0
 X	nop
 X	mov %o0,%o1
 X	sethi %hi(LC4),%o0
 X	or %lo(LC4),%o0,%o0
 X	mov %o1,%o1
 X	call _printf,0
 X	nop
 X.stabn 68,0,40,LM12
 XLM12:
 X	call .div,0
 X	nop
 X	mov %o0,%o1
 X	sethi %hi(LC5),%o0
 X	or %lo(LC5),%o0,%o0
 X	mov %o1,%o1
 X	call _printf,0
 X	nop
 X.stabn 68,0,41,LM13
 XLM13:
 X	call .div,0
 X	nop
 X	mov %o0,%o1
 X	sethi %hi(LC5),%o0
 X	or %lo(LC5),%o0,%o0
 X	mov %o1,%o1
 X	call _printf,0
 X	nop
 X.stabn 68,0,43,LM14
 XLM14:
 X	mov 32,%o4
 X	st %o4,[%fp-36]
 X.stabn 68,0,44,LM15
 XLM15:
 X	ld [%fp-36],%o0
 X	add %o0,5,%o0
 X	st %o0,[%fp-44]
 X.stabn 68,0,45,LM16
 XLM16:
 X	call .div,0
 X	nop
 X	mov %o0,%o0
 X	st %o0,[%fp-52]
 X.stabn 68,0,46,LM17
 XLM17:
 X	sethi %hi(LC6),%o0
 X	or %lo(LC6),%o0,%o0
 X	ld [%fp-36],%o1
 X	ld [%fp-44],%o2
 X	ld [%fp-52],%o3
 X	call _printf,0
 X	nop
 XLBE2:
 X.stabn 68,0,47,LM18
 XLM18:
 XL1:
 X	ret
 X	restore
 X.stabs "_iobuf:T18=s20_cnt:/21,0,32;_ptr:/219=*2,32,32;_base:/219,64,32;_bufsiz:/21,96,32;_flag:/26,128,16;_file:/22,144,8;;~;",128,0,0,0
 X.stabs "_iobuf:t18",128,0,0,0
 X.stabs "main:F1",36,0,0,_main
 X.stabs "ti:1",128,0,0,-20
 X.stabs "tu:4",128,0,0,-28
 X.stabs "ti0:1",128,0,0,-36
 X.stabs "ti1:1",128,0,0,-44
 X.stabs "ti2:1",128,0,0,-52
 X.stabn 192,0,0,LBB2
 X.stabn 224,0,0,LBE2
SHAR_EOF
if test 3557 -ne "`wc -c < 'tuck0.s'`"
then
	echo shar: error transmitting "'tuck0.s'" '(should have been 3557 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'tuck0.script'" '(1614 characters)'
if test -f 'tuck0.script'
then
	echo shar: will not over-write existing file "'tuck0.script'"
else
sed 's/^ X//' << \SHAR_EOF > 'tuck0.script'
 XScript started on Thu Jul  6 15:46:01 1989
 Xtuck@jason> g++ -g tuck0.c
 Xtuck@jason> a.out
 X(5 + 32) / 32 evaluates to 1.
 X(5 + ti) / ti evaluates to 37.
 X(5 + ti) / ti evaluates to 1.
 X(5 + tu) / tu evaluates to 37.
 X(5 + tu) / tu evaluates to 1.
 X37 / 32 evaluates to 1.
 X37 / tu evaluates to 24.
 X37 / tu evaluates to 1.
 X37 / ti evaluates to 24.
 X37 / ti evaluates to 1.
 Xti0 = 32, ti1 = 37, ti2 = 37
 Xtuck@jason> g++ -O tuck0.c
 Xg++: Program cc1plus got fatal signal 4.
 Xtuck@jason> g++ -v -g tuck0.c
 Xg++ version 1.35.1-
 X /mu/hedlund1/gnu/lib/SUN4/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ tuck0.c /tmp/cca09872.cpp
 XGNU CPP version 1.35
 X /mu/hedlund1/gnu/lib/SUN4/gcc-cc1plus /tmp/cca09872.cpp -quiet -dumpbase tuck0.c -noreg -version -G -o /tmp/cca09872.s
 XGNU C++ version 1.35.1- (sparc) compiled by GNU C version 1.35.
 X as /tmp/cca09872.s -o tuck0.o
 X /mu/hedlund1/gnu/lib/SUN4/gcc-ld++ -C /mu/hedlund1/gnu/lib/SUN4/gcc-crt0+.o tuck0.o -lg++ /mu/hedlund1/gnu/lib/SUN4/gcc-gnulib -lg -lc
 Xtuck@jason> echo "CC (AT&T cfront 1.2.1) gives correct output"
 XCC (AT&T cfront 1.2.1) gives correct output
 Xtuck@jason> CC tuck0.c
 Xtuck@jason> a.out
 X(5 + 32) / 32 evaluates to 1.
 X(5 + ti) / ti evaluates to 1.
 X(5 + ti) / ti evaluates to 1.
 X(5 + tu) / tu evaluates to 1.
 X(5 + tu) / tu evaluates to 1.
 X37 / 32 evaluates to 1.
 X37 / tu evaluates to 1.
 X37 / tu evaluates to 1.
 X37 / ti evaluates to 1.
 X37 / ti evaluates to 1.
 Xti0 = 32, ti1 = 37, ti2 = 1
 Xtuck@jason> g++ -g -S tuck0.c
 Xtuck@jason> ^D
 Xscript done on Thu Jul  6 15:48:22 1989
SHAR_EOF
if test 1614 -ne "`wc -c < 'tuck0.script'`"
then
	echo shar: error transmitting "'tuck0.script'" '(should have been 1614 characters)'
fi
fi # end of overwriting check
#	End of shell archive
exit 0
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads