Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2011
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. $ cat test.d 1
  2. import std.stdio;
  3.  
  4. int g(int i) {
  5. auto l = [1, 2, 3, 4];
  6. return l[i];
  7. }
  8.  
  9. void f(int i) {
  10. writeln(g(i));
  11. }
  12.  
  13. void main(string[] args) {
  14. f(1);
  15. f(10);
  16. f(2);
  17. }
  18. $ dmd -gc test.d
  19. $ gdb ./test
  20. GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 8 20:32:45 UTC 2011)
  21. Copyright 2004 Free Software Foundation, Inc.
  22. GDB is free software, covered by the GNU General Public License, and you are
  23. welcome to change it and/or distribute copies of it under certain conditions.
  24. Type "show copying" to see the conditions.
  25. There is absolutely no warranty for GDB. Type "show warranty" for details.
  26. This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .. done
  27.  
  28. (gdb) l
  29. 1 import std.stdio;
  30. 2
  31. 3 int g(int i) {
  32. 4 auto l = [1, 2, 3, 4];
  33. 5 return l[i];
  34. 6 }
  35. 7
  36. 8 void f(int i) {
  37. 9 writeln(g(i));
  38. 10 }
  39. (gdb) l
  40. 11
  41. 12 void main(string[] args) {
  42. 13 f(1);
  43. 14 f(10);
  44. 15 f(2);
  45. 16 }
  46. (gdb) b 14
  47. No line 14 in file "test.d".
  48. (gdb) run
  49. Starting program: /private/tmp/test
  50. Reading symbols for shared libraries +........................ done
  51. 2
  52. core.exception.RangeError@test(5): Range violation
  53. ----------------
  54. 5 test 0x0001023a _d_array_bounds + 30
  55. 6 test 0x00002413 D4test7__arrayZ + 35
  56. 7 test 0x0000247d int test.g(int) + 101
  57. 8 test 0x0000249d void test.f(int) + 17
  58. 9 test 0x000023e2 _Dmain + 26
  59. 10 test 0x000107b3 extern (C) int rt.dmain2.main(int, char**).void runMain() + 23
  60. 11 test 0x0001035d extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate()) + 29
  61. 12 test 0x00010800 extern (C) int rt.dmain2.main(int, char**).void runAll() + 64
  62. 13 test 0x0001035d extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate()) + 29
  63. 14 test 0x000102f7 main + 179
  64. 15 test 0x000023bd start + 53
  65. 16 ??? 0x00000001 0x0 + 1
  66. ----------------
  67.  
  68. Program exited with code 01.
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement