yashinomi / sysdev2020_advanced

0 stars 0 forks source link

Class 2. Exercise 3; log #3

Closed yashinomi closed 3 years ago

yashinomi commented 3 years ago

配列外アクセスして怒られるコード(out_bounds_arr.c)を用意してみた。

$ clang -g  out_boounds_array.c -o bin/out_bounds_array
out_boounds_array.c:6:20: warning: array index 4 is past the end of the array
      (which contains 4 elements) [-Warray-bounds]
    printf("%d\n", arr[4]);
                   ^   ~
out_boounds_array.c:4:5: note: array 'arr' declared here
    int arr[] = {0, 1, 2, 3};
    ^
1 warning generated.

実行してみたけど、怒られなかった.....

$ ./bin/out_bounds_array
3
-359213456
yashinomi commented 3 years ago

NULL 参照するコードref_null.cもセグフォしないから諦め。

$ ./bin/ref_null
-406399336