Created
April 16, 2015 23:51
-
-
Save dobrokot/61959f21609abdea0960 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
#include <string.h> | |
#include <stdio.h> | |
typedef char *p; | |
volatile p src = NULL; | |
volatile p dst = NULL; | |
volatile size_t n = 0; | |
#define TEST(x) if (x) ; else { printf("error, %s\n", #x); } | |
int main() { | |
TEST(dst == memcpy(dst, src, n)); | |
TEST(dst == memmove(dst, src, n)); | |
TEST(dst == strncpy(dst, src, n)); | |
TEST(dst == memset(dst, 0, n)); | |
TEST(0 == strncmp(src, dst, n)); | |
TEST(0 == memcmp(src, dst, n)); | |
/* Observable effect after observable reads from 'volatile n'. | |
OS are not always give explicit message | |
about segmentation fault/invalid read at process termination. */ | |
printf("Still alive. Still alive.\n"); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment