Bug in Microsoft C 5.1
SMITHJ at ohstpy.mps.ohio-state.edu
SMITHJ at ohstpy.mps.ohio-state.edu
Sat Sep 9 03:10:07 AEST 1989
In article <1989Sep7.104322.1210 at gdt.bath.ac.uk>, mapmef at gdr.bath.ac.uk (M E Fletcher) writes:
> I've trimmed my program down substantially so there's for excuse at not
> looking at it now! I already know it's weird and horrible, but that's
> because it's from a larger program which has undergone major surgery.
>
>
> #include <stdio.h>
> static unsigned modulo[9]={0,0,0,0,0,0,0,0,0};
> main()
> {long *timeptr;
> int i;
> unsigned status;
> i=0; while (i!=9)
> {do {status=do_nothing(0,0,0);
> printf("%d\n",i); }
> while (0);
> do {status=do_nothing(0,0,modulo[i]);}
> while (status);
> i++;
> }
> }
> int do_nothing(a,b,c)
> int a,b,c;
> {return(0);}
>
> When I run this instead of printing out 0,1,2,3,4,5 etc. It prints out
> 0,1,1,1,1,1 etc. I think there is a bug in the compiler I am using :
> Micorsoft's 5.1 . Can anyone confirm/deny/reproduce this?
I ran this program on a VAX/VMS using the latest version of VAX C and the
corresct sequence of numbers was printed out so that it does appear as tho'
you have located a bug in the MSC 5.1 compiler.
I suggest that you first try rewriting your program (if possible) so that it
looks more ANSI standard with regards to function calls:
use function(type var,...)
{
/* ... */
}
instead of function(var,...)
type var,..
{
/* ... */
}
I would also suggest changing the init/while constructs you use to 'for' loops.
While these may seem like silly suggestions you would be suprized how quickly
bugs disappear.
I have rewritten your fragment using my suggestions:
#include <stdio.h>
int main(void);
int do_nothing(int a,int b,int c);
static unsigned modulo[9]={0,0,0,0,0,0,0,0,0};
int main(void)
{
long *timeptr;
int i;
unsigned status;
for (i = 0; i != 9; ++i)
{
do
{
status = do_nothing(0,0,0);
printf("%d\n",i);
} while (0);
do
{
status = do_nothing(0,0,modulo[i]);
} while (status);
}
}
int do_nothing(int a,int b,int c)
{
return(0);
}
--
They have one big advantage over us:
*they* know where they're going.
Has your family tried 'em, Powdermilk?
/* Jeffery G. Smith, BS-RHIT (AKA Doc. Insomnia, WMHD-FM) *
* The Ohio State University, Graduate Physics Program *
* 3193 Smith Lab, Columbus, OH 43210 (614) 292-5321 *
* smithj at ohstpy.mps.ohio-state.edu */
More information about the Comp.lang.c
mailing list