delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/05/22/13:39:13

Date: Fri, 22 May 92 18:40:46 GMT
From: kuku AT acds DOT physik DOT rwth-aachen DOT de (Christoph Kukulies)
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: gcc bug?
Status: O

Though I remember a saying of Bob Denny who once said

"When you think you have found a compiler bug then 99 percent it isn't"

the following piece of code causes an exception when run as .exe and
under go32 as well. Could someone else please test it on his/her machine
and confirm/object the faulty behaviour:

#include <stdio.h>
#include <malloc.h>
typedef double ap_Trans3D[4][4];
 
main()
{
	ap_Trans3D p;
	int i;
	double *t;
	p[0][0]=1.0;
	p[1][1]=2.0;
	p[2][2]=3.0;
	p[3][3]=4.0;
	p[3][0]=55.;
	p[0][3]=66.;
	printf("sizeof ap_Trans3D=%d\n",sizeof (ap_Trans3D));
	t = (double *)calloc(1,sizeof (ap_Trans3D));
	for(i=0;i<16;i++)
		t[i]=(double)i;
	mprint(t);
	mprint(p);
}
mprint(t)
ap_Trans3D t;
{
	int i,k;
	printf("------------\n");
	for(i=0;i<4;i++,printf("\n"))
		for(k=0;k<4;k++)
			printf("%3.1lf ",t[i][k]),fflush(stdout);
}

it prints:

------------
 0.0  1.0  2.0  3.0 
 4.0  5.0  6.0  7.0 
 8.0  9.0 10.0 11.0 
12.0 13.0 14.0 15.0 
------------
 1.0  0.0  0.0 66.0 
 0.0  2.0  0.0  0.0 
 0.0  0.0  3.0  Exception at eip=21f8

I'm stymied.


--Chris

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019