Created
January 11, 2017 16:17
-
-
Save sehugg/cee99a43bca7a791467644b4d7bc64b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// duplicates static variable bug for CC65 | |
#include <stdio.h> | |
#include <limits.h> | |
unsigned char success=0; | |
unsigned char failures=0; | |
unsigned char dummy=0; | |
#define COUNT 256 /* Up to what number? */ | |
#define SQRT_COUNT 16 /* Sqrt of COUNT */ | |
typedef unsigned char byte; | |
static byte Sieve[COUNT]; | |
void sieve2() | |
{ | |
register unsigned int i; | |
register unsigned int k; | |
static unsigned int prime; | |
for (i=0; i<COUNT; i++) { | |
Sieve[i] = 1; | |
} | |
for (i=0; i<COUNT; i++) { | |
if (Sieve[i]) { | |
prime = i+i+3; | |
k = i+prime; | |
while (k <= COUNT) { | |
Sieve[k] = 0; | |
k += prime; | |
} | |
} | |
} | |
} | |
int main(void) | |
{ | |
register unsigned int i; | |
static unsigned int prime; | |
i = 1; | |
prime = i+i+3; | |
failures += (prime != 5); | |
sieve2(); | |
return failures; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment