diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2019-09-26 11:35:01 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2019-09-26 11:35:01 +0900 |
commit | 1fe73dc8609c4bac9e517dc70f602a16dae556cc (patch) | |
tree | 852c00b143358a8d5f8c4b1ff114082b9664eff4 /string.c | |
parent | 5357ceb1ca454e2b3c5c173c638054cf705e4752 (diff) | |
download | ruby-1fe73dc8609c4bac9e517dc70f602a16dae556cc.tar.gz |
include/ruby/ruby.h: suppress a false-positive warning of GCC
GCC emits a lot of false positives for rb_scan_args because:
* `rb_scan_args(argc, argv, "*:", NULL, &opts);` makes `n_mand == 0`,
* `n_mand == argc + 1` implies `argc == -1`, and
* `memcpy(ptr, argv, sizeof(VALUE)*argc);` explodes
However, we know that argc is never so big, thus this is a false
positive. This change suppresses it by adding a condition `n_mand > 0`.
```
In file included from /usr/include/string.h:494,
from ./include/ruby/defines.h:145,
from ./include/ruby/ruby.h:29,
from ./include/ruby/encoding.h:27,
from dir.c:14:
In function 'memcpy',
inlined from 'ruby_nonempty_memcpy.part.0' at ./include/ruby/ruby.h:1763:17,
inlined from 'ruby_nonempty_memcpy' at ./include/ruby/ruby.h:1760:1,
inlined from 'rb_scan_args_set' at ./include/ruby/ruby.h:2594:9,
inlined from 'dir_s_aref' at dir.c:2774:12:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:34:10: warning: '__builtin___memcpy_chk' pointer overflow between offset 0 and size [-8, 9223372036854775807] [-Warray-bounds]
return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:34:10: warning:
'__builtin___memcpy_chk' specified size 18446744073709551608 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
```
Diffstat (limited to 'string.c')
0 files changed, 0 insertions, 0 deletions