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=]
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);
makesn_mand == 0
,n_mand == argc + 1
impliesargc == -1
, andmemcpy(ptr, argv, sizeof(VALUE)*argc);
explodesHowever, 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
.