Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#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
You can’t perform that action at this time.