the original´s source is from freebasic examples. the problem is, when compile without optimization, the program never end.
with optimization the program run well.
is this a compiler´s bug?
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#define INTERATIONS 10000
int main(int argc, char *argv[])
{
	int Flags[8190];
	int iter;
	int count;
	int prime;
	int k;
	int i;
	long x;
	x = GetTickCount();
	for (iter = 0; iter < INTERATIONS; iter++)
	{
		count = 0;
		for (i = 0; i < 8190; i++)
			Flags[i] = 1;
		for (i = 0; i < 8190; i++)
		{
			if (Flags[i] == 1)
			{
				prime = (i * 2) + 3;
				k = i + prime;
				while (k <= 8190)
				{
					Flags[k] = 0;
					k = k + prime;
				}
				count++;
			}
		}
	}
	x = GetTickCount() - x;
	printf("msecs taken:%d\ncount:%d\n", x, count);
	return 0;
}
sorry for my english.
			
			
			
				Quote from: "denise_amiga"
is this a compiler´s bug?
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#define INTERATIONS 10000
int main(int argc, char *argv[])
{
	int Flags[8190];
	int iter;
	int count;
	int prime;
	int k;
	int i;
	long x;
				while (k <= 8190)
				{
					Flags[k] = 0;
					k = k + prime;
				}
}
It is a "little" bug in your program not in the compiler.
You have an array with 8190 members and you ask for k <= 8190. So you can point to then 8191th position and there are other variables stored witch are deleted if you meet this position. :? 
When you use an optimizer this variables are kept in register and this error did not occur.
			
 
			
			
				ok thx.