From owner-svn-src-head@freebsd.org Fri Oct 16 14:28:14 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B3F37437A43; Fri, 16 Oct 2020 14:28:14 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CCT5p3kV7z3XVC; Fri, 16 Oct 2020 14:28:14 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 633C41195C; Fri, 16 Oct 2020 14:28:14 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09GESEUa085458; Fri, 16 Oct 2020 14:28:14 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09GESEoj085457; Fri, 16 Oct 2020 14:28:14 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <202010161428.09GESEoj085457@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Fri, 16 Oct 2020 14:28:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366765 - head/contrib/libgnuregex X-SVN-Group: head X-SVN-Commit-Author: adrian X-SVN-Commit-Paths: head/contrib/libgnuregex X-SVN-Commit-Revision: 366765 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Oct 2020 14:28:14 -0000 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 == '_')