From owner-freebsd-current@FreeBSD.ORG Fri Feb 7 18:04:43 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 77CE52C3; Fri, 7 Feb 2014 18:04:43 +0000 (UTC) Received: from mail-we0-x231.google.com (mail-we0-x231.google.com [IPv6:2a00:1450:400c:c03::231]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7343618C9; Fri, 7 Feb 2014 18:04:42 +0000 (UTC) Received: by mail-we0-f177.google.com with SMTP id t61so2473553wes.8 for ; Fri, 07 Feb 2014 10:04:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=EPpHZRIQns5b3v4l/FKGuYGgGk1Tzn3yj7YN5zKlXvc=; b=mddps6Oy3IWm11exk4AusBBdLCZdM1ZxZ7Le87b8ozxtt0NpDTEvdc526oJKN4SqLu yAS/CYc9cDWuKuEwBevZCRotDo9b1OUPh7THhnmKdQgKPl4XyVg19ZgqIKPHD8mfo6A9 U0ziuBP8W5MTyM285ataU9I/Et85IFTIFsiP/VKiP0NDCXzQ+VRCXSVe5ThhMKrhx0Ee 5VM8BFtTUYfFmoBatfkDTDbD+85DN9GdtE+ewLHYaRKZLiXRhGZxmPWnQPAanCPFFejV 0nMXkBNx7ZMRn/yPZhNpPuwYCxdWdQVRyrsT4IGYxcQbetl4pd+ltnrNet3rnNDSkgnr R9kQ== MIME-Version: 1.0 X-Received: by 10.194.63.228 with SMTP id j4mr11907621wjs.34.1391796280784; Fri, 07 Feb 2014 10:04:40 -0800 (PST) Sender: asomers@gmail.com Received: by 10.194.168.197 with HTTP; Fri, 7 Feb 2014 10:04:40 -0800 (PST) Date: Fri, 7 Feb 2014 11:04:40 -0700 X-Google-Sender-Auth: cZVPRDvroqnToXM8gnRB5I2H6nM Message-ID: Subject: contrib/libc++/include/locale contains -Wsign-compare errors From: Alan Somers To: FreeBSD CURRENT , "freebsd-testing@freebsd.org" , theraven@freebsd.org, Brooks Davis , Dimitry Andric Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Feb 2014 18:04:43 -0000 contrib/libc++/include/locale compares integers of different signs. With our CXXFLAG settings, this causes "WITH_TESTS=1 make buildworld" to fail while compiling libatf-c++, as I mentioned in another thread. I've now written a minimal test case. Just #include locale and compile it with the right settings. $ cat use_locale.cpp #include $ c++ -Wsystem-headers -Werror -Wsign-compare -Wno-unused-parameter -Wno-c++11-extensions -c -o use_locale.o use_locale.cpp In file included from use_locale.cpp:1: /usr/include/c++/v1/locale:1016:27: error: comparison of integers of different signs: 'long' and 'size_type' (aka 'unsigned long') [-Werror,-Wsign-compare] if (__a_end - __a == __buf.size()) ~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~ /usr/include/c++/v1/locale:1066:27: error: comparison of integers of different signs: 'long' and 'size_type' (aka 'unsigned long') [-Werror,-Wsign-compare] if (__a_end - __a == __buf.size()) ~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~ /usr/include/c++/v1/locale:1120:27: error: comparison of integers of different signs: 'long' and 'size_type' (aka 'unsigned long') [-Werror,-Wsign-compare] if (__a_end - __a == __buf.size()) ~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~ 3 errors generated. The below patch fixes the problem, but I don't have the confidence to change the system C++ library myself. Can somebody please review it? Index: contrib/libc++/include/locale =================================================================== --- contrib/libc++/include/locale (revision 261283) +++ contrib/libc++/include/locale (working copy) @@ -1012,7 +1012,7 @@ unsigned __dc = 0; for (; __b != __e; ++__b) { - if (__a_end - __a == __buf.size()) + if ((size_t)(__a_end - __a) == __buf.size()) { size_t __tmp = __buf.size(); __buf.resize(2*__buf.size()); @@ -1062,7 +1062,7 @@ unsigned __dc = 0; for (; __b != __e; ++__b) { - if (__a_end - __a == __buf.size()) + if ((size_t)(__a_end - __a) == __buf.size()) { size_t __tmp = __buf.size(); __buf.resize(2*__buf.size()); @@ -1116,7 +1116,7 @@ char __exp = 'E'; for (; __b != __e; ++__b) { - if (__a_end - __a == __buf.size()) + if ((size_t)(__a_end - __a) == __buf.size()) { size_t __tmp = __buf.size(); __buf.resize(2*__buf.size());