Perhaps because you forgot to call malloc ?
Code:
$ gcc -W -Wall -Wextra -g bar.c
$ gdb ./a.out
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/sc/Documents/coding/a.out...done.
(gdb) run
Starting program: /home/sc/Documents/coding/a.out
Program received signal SIGSEGV, Segmentation fault.
memcpy () at ../sysdeps/x86_64/memcpy.S:91
91 ../sysdeps/x86_64/memcpy.S: No such file or directory.
in ../sysdeps/x86_64/memcpy.S
(gdb) where
#0 memcpy () at ../sysdeps/x86_64/memcpy.S:91
#1 0x000000000040063d in test2 (v=0xa <Address 0xa out of bounds>) at bar.c:15
#2 0x0000000000400697 in main () at bar.c:27
Your address is 10, not a pointer to 10 bytes.