9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] lmbench vs 8c
@ 1998-07-11  8:29 schwartz
  0 siblings, 0 replies; 3+ messages in thread
From: schwartz @ 1998-07-11  8:29 UTC (permalink / raw)


The latest version of Larry McVoy's lmbench exercises the compiler 
in fun ways.  Here's one:

% cat reg.c
void
doit(void)
{
	register int *p;
	int sum;

	sum =
	p[0]+p[1]+p[2]+p[3]+p[4]+p[5]+p[6]+p[7]+
	p[8]+p[9]+p[10]+p[11]+p[12]+p[13]+p[14]+
	p[15]+p[16]+p[17]+p[18]+p[19]+p[20]+p[21]+
	p[22]+p[23]+p[24]+p[25]+p[26]+p[27]+p[28]+
	p[29]+p[30]+p[31]+p[32]+p[33]+p[34]+p[35]+
	p[36]+p[37]+p[38]+p[39]+p[40]+p[41]+p[42]+
	p[43]+p[44]+p[45]+p[46]+p[47]+p[48]+p[49]+
	p[50]+p[51]+p[52]+p[53]+p[54]+p[55]+p[56]+
	p[57]+p[58]+p[59]+p[60]+p[61]+p[62]+p[63]+
	p[64]+p[65]+p[66]+p[67]+p[68]+p[69]+p[70]+
	p[71]+p[72]+p[73]+p[74]+p[75]+p[76]+p[77]+
	p[78]+p[79]+p[80]+p[81]+p[82]+p[83]+p[84]+
	p[85]+p[86]+p[87]+p[88]+p[89]+p[90]+p[91]+
	p[92]+p[93]+p[94]+p[95]+p[96]+p[97]+p[98]+
	p[99]+p[100]+p[101]+p[102]+p[103]+p[104]+
	p[105]+p[106]+p[107]+p[108]+p[109]+p[110]+
	p[111]+p[112]+p[113]+p[114]+p[115]+p[116]+
	p[117]+p[118]+p[119]+p[120]+p[121]+p[122]+
	p[123]+p[124]
	/* ok so far */
	+p[125] /* not ok */
	/* 
	+p[126]+p[127]
	*/
	;
}

% 8c reg.c
reg.c:10 error in regfree: 8
reg.c:10 error in regfree: 8
reg.c:10 error in regfree: 8
reg.c:10 error in regfree: 8
reg.c:10 error in regfree: 8
reg.c:10 error in regfree: 8
reg.c:10 error in regfree: 8
reg.c:10 error in regfree: 8
reg.c:10 error in regfree: 8
reg.c:10 error in regfree: 8
reg.c:10 error in regfree: 8
too many errors





^ permalink raw reply	[flat|nested] 3+ messages in thread

* [9fans] lmbench vs 8c
@ 1998-07-11 23:56 Scott
  0 siblings, 0 replies; 3+ messages in thread
From: Scott @ 1998-07-11 23:56 UTC (permalink / raw)


Brandon Black <photon@dtmf.com> writes:
| Interesting.... but do you get the same problems with semi-valid code?

The original program was completely valid.  I chopped it down just to
the point where the compiler bug manifested.

The fix (from bobf and ken) is to change, in gc.h, 
	char reg[D_NONE];
to 
	int reg[D_NONE];

And to change the initialization in txt.c to use a loop instead of memset.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [9fans] lmbench vs 8c
@ 1998-07-11 20:45 Brandon
  0 siblings, 0 replies; 3+ messages in thread
From: Brandon @ 1998-07-11 20:45 UTC (permalink / raw)


Interesting.... but do you get the same problems with semi-valid code?
(I don't have plan9 installed currently, can't check myself).  p is
uninitialized.... I wouldn't think that would affect things in this
compiler test, only at runtime... what happens if you actually create
the array being referenced, and set p to the beginning of the array, and
then test?

Brandon

schwartz@bio.cse.psu.edu wrote:

> The latest version of Larry McVoy's lmbench exercises the compiler
> in fun ways.  Here's one:
>
> % cat reg.c
> void
> doit(void)
> {
>         register int *p;
>         int sum;
>
>         sum =
>         p[0]+p[1]+p[2]+p[3]+p[4]+p[5]+p[6]+p[7]+
>         p[8]+p[9]+p[10]+p[11]+p[12]+p[13]+p[14]+
>         p[15]+p[16]+p[17]+p[18]+p[19]+p[20]+p[21]+
>         p[22]+p[23]+p[24]+p[25]+p[26]+p[27]+p[28]+
>         p[29]+p[30]+p[31]+p[32]+p[33]+p[34]+p[35]+
>         p[36]+p[37]+p[38]+p[39]+p[40]+p[41]+p[42]+
>         p[43]+p[44]+p[45]+p[46]+p[47]+p[48]+p[49]+
>         p[50]+p[51]+p[52]+p[53]+p[54]+p[55]+p[56]+
>         p[57]+p[58]+p[59]+p[60]+p[61]+p[62]+p[63]+
>         p[64]+p[65]+p[66]+p[67]+p[68]+p[69]+p[70]+
>         p[71]+p[72]+p[73]+p[74]+p[75]+p[76]+p[77]+
>         p[78]+p[79]+p[80]+p[81]+p[82]+p[83]+p[84]+
>         p[85]+p[86]+p[87]+p[88]+p[89]+p[90]+p[91]+
>         p[92]+p[93]+p[94]+p[95]+p[96]+p[97]+p[98]+
>         p[99]+p[100]+p[101]+p[102]+p[103]+p[104]+
>         p[105]+p[106]+p[107]+p[108]+p[109]+p[110]+
>         p[111]+p[112]+p[113]+p[114]+p[115]+p[116]+
>         p[117]+p[118]+p[119]+p[120]+p[121]+p[122]+
>         p[123]+p[124]
>         /* ok so far */
>         +p[125] /* not ok */
>         /*
>         +p[126]+p[127]
>         */
>         ;
> }
>
> % 8c reg.c
> reg.c:10 error in regfree: 8
> reg.c:10 error in regfree: 8
> reg.c:10 error in regfree: 8
> reg.c:10 error in regfree: 8
> reg.c:10 error in regfree: 8
> reg.c:10 error in regfree: 8
> reg.c:10 error in regfree: 8
> reg.c:10 error in regfree: 8
> reg.c:10 error in regfree: 8
> reg.c:10 error in regfree: 8
> reg.c:10 error in regfree: 8
> too many errors







^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1998-07-11 23:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-07-11  8:29 [9fans] lmbench vs 8c schwartz
1998-07-11 20:45 Brandon
1998-07-11 23:56 Scott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).