Sergey Poznyakoff wrote: > With recent gnulib (v0.1-4336-gbdae9a5), attempting to compile > parse-datetime.c fails with: > > $ make -k parse-datetime.o V=1 > gcc -DHAVE_CONFIG_H -I. -I.. -Wall -ggdb -MT parse-datetime.o -MD -MP -MF > .deps/parse-datetime.Tpo -c -o parse-datetime.o parse-datetime.c > In file included from parse-datetime.y:39:0: > parse-datetime.y: In function 'to_tm_year': > intprops.h:578:17: warning: integer overflow in expression [-Woverflow] > || (tmax) + (b) < (a))) > ^ > intprops.h:524:4: note: in expansion of macro > '_GL_INT_SUBTRACT_RANGE_OVERFLOW' > (overflow (a, b, tmin, tmax) \ > ^ > intprops.h:491:10: note: in expansion of macro '_GL_INT_OP_CALC' > ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ > ^ > intprops.h:389:4: note: in expansion of macro '_GL_INT_OP_WRAPV' > _GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW) > ^ > parse-datetime.y:1274:9: note: in expansion of macro 'INT_SUBTRACT_WRAPV' > : INT_SUBTRACT_WRAPV (year, TM_YEAR_BASE, tm_year)) > ^ > parse-datetime.y: In function 'yylex': > intprops.h:578:17: warning: integer overflow in expression [-Woverflow] > || (tmax) + (b) < (a))) > ^ > intprops.h:524:4: note: in expansion of macro > '_GL_INT_SUBTRACT_RANGE_OVERFLOW' > (overflow (a, b, tmin, tmax) \ > ^ > intprops.h:500:11: note: in expansion of macro '_GL_INT_OP_CALC' > ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ > ^ > intprops.h:495:7: note: in expansion of macro '_GL_INT_OP_WRAPV_LONGISH' > : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow)) > ^ > intprops.h:389:4: note: in expansion of macro '_GL_INT_OP_WRAPV' > _GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW) > ^ > parse-datetime.y:1469:23: note: in expansion of macro 'INT_SUBTRACT_WRAPV' > if (INT_SUBTRACT_WRAPV (s, 1, &s)) > ^
The compilation doesn't fail; it merely shows warning. When I modify intprops.h to behave the same for all GCC versions as for GCC 5.x, I see: * The warning is there for all GCC versions < 10, but is fixed in GCC 10.2.0. * GCC 9.3.0 has more details: In file included from parse-datetime.y:39: parse-datetime.y: In function 'to_tm_year': intprops.h:576:17: warning: integer overflow in expression of type 'int' results in '-2147481749' [-Woverflow] 576 | || (tmax) + (b) < (a))) | ^ intprops.h:522:4: note: in expansion of macro '_GL_INT_SUBTRACT_RANGE_OVERFLOW' 522 | (overflow (a, b, tmin, tmax) \ | ^~~~~~~~ intprops.h:489:10: note: in expansion of macro '_GL_INT_OP_CALC' 489 | ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \ | ^~~~~~~~~~~~~~~ intprops.h:389:4: note: in expansion of macro '_GL_INT_OP_WRAPV' 389 | _GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW) | ^~~~~~~~~~~~~~~~ parse-datetime.y:1274:9: note: in expansion of macro 'INT_SUBTRACT_WRAPV' 1274 | : INT_SUBTRACT_WRAPV (year, TM_YEAR_BASE, tm_year)) | ^~~~~~~~~~~~~~~~~~ parse-datetime.y: In function 'yylex': intprops.h:576:17: warning: integer overflow in expression of type 'long int' results in '-9223372036854775808' [-Woverflow] 576 | || (tmax) + (b) < (a))) | ^ intprops.h:522:4: note: in expansion of macro '_GL_INT_SUBTRACT_RANGE_OVERFLOW' 522 | (overflow (a, b, tmin, tmax) \ | ^~~~~~~~ intprops.h:498:11: note: in expansion of macro '_GL_INT_OP_CALC' 498 | ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \ | ^~~~~~~~~~~~~~~ intprops.h:493:7: note: in expansion of macro '_GL_INT_OP_WRAPV_LONGISH' 493 | : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow)) | ^~~~~~~~~~~~~~~~~~~~~~~~ intprops.h:389:4: note: in expansion of macro '_GL_INT_OP_WRAPV' 389 | _GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW) | ^~~~~~~~~~~~~~~~ parse-datetime.y:1469:23: note: in expansion of macro 'INT_SUBTRACT_WRAPV' 1469 | if (INT_SUBTRACT_WRAPV (s, 1, &s)) | ^~~~~~~~~~~~~~~~~~ So, the problem is a signed-integer overflow of constants in a dead (unreachable) code branch. Bruno