Author: adrian Date: Fri Oct 16 14:28:13 2020 New Revision: 366765 URL: https://svnweb.freebsd.org/changeset/base/366765
Log: This fixes some fun type size truncation that shows up giving errors like " changes value from '287948901175001088' to '0' " .. which turns out is a known issue with later gcc's. eg - https://lists.gnu.org/archive/html/bug-gnulib/2012-03/msg00154.html It was fixed up upstream corelib/gnulib in commit hash 252b52457da7887667c036d18cc5169777615bb0 (eg in https://github.com/coreutils/gnulib/commit/252b52457da7887667c036d18cc5169777615bb0) TEST PLAN - compiled/run for gcc-6.4 on amd64 Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D26804 Modified: head/contrib/libgnuregex/regcomp.c Modified: head/contrib/libgnuregex/regcomp.c ============================================================================== --- head/contrib/libgnuregex/regcomp.c Fri Oct 16 13:37:58 2020 (r366764) +++ head/contrib/libgnuregex/regcomp.c Fri Oct 16 14:28:13 2020 (r366765) @@ -930,26 +930,30 @@ init_word_char (re_dfa_t *dfa) int ch = 0; if (BE (dfa->map_notascii == 0, 1)) { - if (sizeof (dfa->word_char[0]) == 8) + /* Avoid uint32_t and uint64_t as some non-GCC platforms lack + them, an issue when this code is used in Gnulib. */ + bitset_word_t bits0 = 0x00000000; + bitset_word_t bits1 = 0x03ff0000; + bitset_word_t bits2 = 0x87fffffe; + bitset_word_t bits3 = 0x07fffffe; + + if (BITSET_WORD_BITS == 64) { - /* The extra temporaries here avoid "implicitly truncated" - warnings in the case when this is dead code, i.e. 32-bit. */ - const uint64_t wc0 = UINT64_C (0x03ff000000000000); - const uint64_t wc1 = UINT64_C (0x07fffffe87fffffe); - dfa->word_char[0] = wc0; - dfa->word_char[1] = wc1; + /* Pacify gcc -Woverflow on 32-bit platformns. */ + dfa->word_char[0] = bits1 << 31 << 1 | bits0; + dfa->word_char[1] = bits3 << 31 << 1 | bits2; i = 2; } - else if (sizeof (dfa->word_char[0]) == 4) + else if (BITSET_WORD_BITS == 32) { - dfa->word_char[0] = UINT32_C (0x00000000); - dfa->word_char[1] = UINT32_C (0x03ff0000); - dfa->word_char[2] = UINT32_C (0x87fffffe); - dfa->word_char[3] = UINT32_C (0x07fffffe); + dfa->word_char[0] = bits0; + dfa->word_char[1] = bits1; + dfa->word_char[2] = bits2; + dfa->word_char[3] = bits3; i = 4; } else - abort (); + goto general_case; ch = 128; if (BE (dfa->is_utf8, 1)) @@ -959,6 +963,7 @@ init_word_char (re_dfa_t *dfa) } } +general_case: for (; i < BITSET_WORDS; ++i) for (int j = 0; j < BITSET_WORD_BITS; ++j, ++ch) if (isalnum (ch) || ch == '_') _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"