Skip to content

Instantly share code, notes, and snippets.

@krono
Last active January 2, 2016 22:29
Show Gist options
  • Save krono/8370437 to your computer and use it in GitHub Desktop.
Save krono/8370437 to your computer and use it in GitHub Desktop.
#include <stdio.h>
void foo(void) {
static int barf=10;
barf++;
}
int main()
{
printf("test: %d\n", (int)foo());
printf("test: %d\n", (int)foo());
return 0;
}
/* does not compile on
on clang 5, gcc-4.8
BUT prints
test: 11
test: 12
on tcc 0.9.6
*/
#include <stdio.h>
void foo(void) {
static int barf=10;
barf++;
}
int (*foo_)(void) = (int(*)(void))foo;
int main()
{
printf("test: %d\n", foo_());
printf("test: %d\n", foo_());
return 0;
}
/* prints
test: 11
test: 12
on clang 5, gcc-4.8, tcc 0.9.6
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment