Skip to content

Instantly share code, notes, and snippets.

@dmaclach
Last active August 9, 2020 16:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmaclach/b10b0a71ae614d304c067cb9bd264336 to your computer and use it in GitHub Desktop.
Save dmaclach/b10b0a71ae614d304c067cb9bd264336 to your computer and use it in GitHub Desktop.
Compile this with Xcode 11 "release" and it will crash on ARMv7 due to misaligned read. Use a "single view" iOS App as your template, and replace AppDelegate.m with this code.
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@end
__attribute__((noinline)) double GPBCodedInputStreamReadDouble(uint8_t *buf) {
int64_t value = OSReadLittleInt64(buf, 0);
double result;
memcpy(&result, &value, sizeof(result));
return result;
}
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
double data[3] = {1, 2};
uint8_t *bytes = ((uint8_t*)(data)) + 1;
double a = GPBCodedInputStreamReadDouble(bytes);
NSLog(@"%f", a);
return YES;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment