Skip to content

Instantly share code, notes, and snippets.

@mkrautz
Last active August 29, 2015 14:10
Show Gist options
  • Save mkrautz/ef6ea55f41e092a9f4b3 to your computer and use it in GitHub Desktop.
Save mkrautz/ef6ea55f41e092a9f4b3 to your computer and use it in GitHub Desktop.
MSVC 2013 crasher
// Build with "cl -O2 /fp:fast crash.c"
#include <stdio.h>
#include <stdlib.h>
#define IMIN(a,b) (float)(a>b?a:b)
struct TonalityAnalysis {
int count;
float std[4];
};
int main() {
int i;
struct TonalityAnalysis *tonal = malloc(sizeof(struct TonalityAnalysis));
tonal->count = 6;
for (i=0;i<4;i++)
tonal->std[i]=(float)i;
printf("tonal = %p\n", tonal);
printf("tonal->std = %p\n", &tonal->std[0]);
float alpha = 1.f/IMIN(20, 1+tonal->count);
float features[4];
for (i=0;i<4;i++)
features[i]=(float)i;
if (tonal->count > 6) {
for (i=0;i<4;i++)
tonal->std[i] = (1-alpha)*tonal->std[i] + alpha*features[i]*features[i];
}
for (i=0;i<4;i++)
features[i] = (float)sqrt(tonal->std[i]);
for (i=0;i<4;i++)
printf("%.2f\n", features[i]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment