Re: checked integer arithmetic

2016-12-15 Thread Paul Eggert
Bruno Haible wrote: 1) You're basically saying "let's use signed integer types for indices", and you do that in the quotearg.c change. Yes. This is not my invention; it's common in C programs generally to use int for indexes. Using ptrdiff_t for indexes is the preferred coding style in the C

Re: checked integer arithmetic

2016-12-15 Thread Bruno Haible
> For this purpose, it would be good if GCC had a type, say, __gcc_index_t, > that -fsanitize=undefined will make produce a diagnostic is a value < 0 > or > PTRDIFF_MAX is assigned. Actually, this is a special case of a range type. If we could have Ada's range types [1] in C, with overflow check e

Re: checked integer arithmetic

2016-12-15 Thread Bruno Haible
Hi Paul, > I installed the patch I proposed yesterday, along with the > additional patches attached, which merely change the x* functions to > check for both kinds of overflow. These changes give me some stomach-ache. I perfectly understand that you're making a departure from 20 years of C trad

init.sh: add option to preserve temporary files

2016-12-15 Thread Bruno Haible
Hi, init.sh is used in the GNU gettext test suite, and I frequently have the need to inspect temporary files after a test failure (or even after an unexpected test pass). Therefore here's a proposed patch that introduces an option to do this. 2016-12-15 Bruno Haible init.sh: Add poss

Re: checked integer arithmetic

2016-12-15 Thread Paul Eggert
On 12/15/2016 02:09 AM, Bruno Haible wrote: So, the limiting factor is the pointer difference operator ptr1 - ptr2where sizeof (*ptr1,*ptr2) > 1. Yes, it is the pointer difference operator. However, the problem occurs even with size-1 array elements. For example: #include #inclu

Re: bug#22357: grep -f not only huge memory usage, but also huge time cost

2016-12-15 Thread L.A. Walsh
Norihiro Tanaka wrote: dfa matcher is not always slower than kws matcher. - $ env LC_ALL=C grep -F -w 0 k - $ env LC_ALL=C grep -F -w -f /usr/share/dict/words /dev/null First is faster after the changes, and second is slower after the changes. It's a trade-off. Can you have any idea to select

Re: C++ aliases in

2016-12-15 Thread Gisle Vanem
> I've not checked all test-*.cc files for such errors. Another issue with sys_select.in.h: test-sys_select-c++.cc sys/select.h(305): error C2440: 'return': cannot convert from 'int (__cdecl *)(int,fd_set *,fd_set *,fd_set *,timeval *)' to 'gnulib_::_gl_select_wrapper::type' sys/select.h

C++ aliases in

2016-12-15 Thread Gisle Vanem
I get errors from MSVC in i C++ mode. E.g. in compiling test-netdb-c++.cc: netdb.h(189): error C2440: 'return': cannot convert from 'INT (__stdcall *)(PCSTR,PCSTR,const ADDRINFOA *,PADDRINFOA *)' to 'gnulib_::_gl_getaddrinfo_wrapper::type' Ditto error for '_gl_freeaddrinfo_wrapper'. Some

Re: checked integer arithmetic

2016-12-15 Thread Bruno Haible
Paul Eggert wrote: > #include > #include > #include > > ptrdiff_t > diff (short *a, short *b) > { >return a - b; > } > > int > main (void) > { >size_t n = PTRDIFF_MAX / sizeof (short) + 1; >short *x = malloc (n * sizeof (short)); >return 0 < diff (x + n, x); > } I can reproduc