Created
March 20, 2019 16:14
-
-
Save ztane/ed60a0cf8b4fba4a318cabacfae493b6 to your computer and use it in GitHub Desktop.
clang ub stuff
This file contains hidden or 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
#include <stdio.h> | |
#define BUGGY | |
void funcA(int s, int g) | |
{ | |
int i, j = 0, k; | |
int grp[4] = {-1, -1}; | |
for (i = 0, k = 0; i < 1; ++i) { | |
for (j = 0; j < 1; ++j) { | |
if ( grp[g] > 0 ) | |
{ | |
if ( g > 5 ) { | |
continue; | |
} | |
else { | |
#ifdef BUGGY | |
*(long long *)grp = 0; | |
#else | |
*(int *)grp = 0; | |
*(((int *)grp) + 1) = 0; | |
#endif | |
} | |
} | |
grp[k++] = 0; | |
} | |
printf("this should be zero: %d\n", grp[0]); | |
} | |
} | |
int main(void) { | |
funcA(0, 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
seems to be more mimimal