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> | |
#include <stdlib.h> | |
void | |
invalid_code(void) | |
{ | |
void (^block)(void); | |
if (rand() % 2) { | |
block = ^{ printf("odd\n"); }; | |
} else { |
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
__attribute__((warn_unused_result)) | |
id my_func(int a, int b, int c); | |
#define my_func(a, b, c) \ | |
_Pragma("clang diagnostic push") \ | |
_Pragma("clang diagnostic error \"-Wunused-result\"") \ | |
my_func(a, b, c) \ | |
_Pragma("clang diagnostic pop") |
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
@implementation MyClass | |
+ (instancetype)sharedInstanceWithError:(NSError **)error | |
{ | |
static _Atomic(MyClass *) sMyClass; | |
MyClass *tmp = nil, *expected = nil; | |
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__arm64__) | |
// this assumes that this platform has consume ordering | |
// for loads through dereferencing pointers, which both intel & arm have. |
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
bool is_even(unsigned n) | |
{ | |
char buf[11]; | |
sprintf(buf, "%10u", n); | |
switch (buf[9]) { | |
case '0': return true; | |
case '1': return false; | |
default: return is_even(buf[9]); | |
} |