Add tiny C example of null pointer error.

master
Rohan Jacob-Rao 9 years ago
parent e9f1f03aa0
commit 8fbe358b34

@ -0,0 +1,4 @@
void foo(void) {
int *p = 0;
*p = 42;
}

@ -0,0 +1,18 @@
; ModuleID = 'null_deref.c'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.10.0"
; Function Attrs: nounwind ssp uwtable
define void @foo() #0 {
%p = alloca i32*, align 8
store i32* null, i32** %p, align 8
%1 = load i32** %p, align 8
store i32 42, i32* %1, align 4
ret void
}
attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
!llvm.ident = !{!0}
!0 = metadata !{metadata !"Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)"}
Loading…
Cancel
Save