Skip to content

Instantly share code, notes, and snippets.

@Keith-S-Thompson
Keith-S-Thompson / README.md
Created February 15, 2014 00:43
Markdown sandbox

One hash

Two hashes

Three hashes

Four hashes

Five hashes
/*
* In response to http://stackoverflow.com/a/22918463/827263
* "In C you can't declare variables/functions (in same scope) with the same name more than once."
*/
#include <stdio.h>
void yes_you_can(void);
void yes_you_can(void);
void yes_you_can(void);
#include <stdio.h>
#include <stdint.h>
int main(void) {
int64_t u = 0;
int i;
for(i=0;i<44;i++)
u |= (uint64_t)1 << i;
@Keith-S-Thompson
Keith-S-Thompson / README.md
Last active August 29, 2015 14:03
clang _Generic bug
@Keith-S-Thompson
Keith-S-Thompson / README.md
Last active August 29, 2015 14:06
g++ bug demo
@Keith-S-Thompson
Keith-S-Thompson / README.md
Last active August 29, 2015 14:07
gcc/clang pointer equality bug demo

I believe I've found a bug in the implementation of the "==" operator for pointers in both gcc and clang.

pointer_equality_bug.c is a demonstration of the bug.

Quoting N1570 6.5.9p6:

Two pointers compare equal if and only if both are null pointers,

This is a CVS demo script for this question posted by Paul Bunch on Stack Overflow.

The cvs annotate command prints a message on standard error of the form:

Annotations for hello.txt
***************

The questioner is trying to redirect that message when invoking cvs annotate from a Perl script. I have so far been unable to reproduce the problem. I ask Paul Bunch to try running this script on his own system.

@Keith-S-Thompson
Keith-S-Thompson / foo.txt
Created December 15, 2011 21:52
Just a gist
This is foo.txt.
I'm just trying out this "gist" thing.
Hey, and I can edit it!
@Keith-S-Thompson
Keith-S-Thompson / c.c
Created February 7, 2012 01:48
offsetof() example
/*
* Reference: http://stackoverflow.com/questions/9169453/gcc-4-4-3-offsetof-constant-expression-bug-how-should-i-work-around-this
* Should compile and execute without error or warning with:
* gcc c.c -pedantic -std=c89 -o c && ./c
* or
* gcc c.c -pedantic -std=c99 -o c && ./c
*/
#include <stddef.h>
#include <stdlib.h>