From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 0CA43385841B for ; Thu, 13 Jan 2022 20:24:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0CA43385841B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-x433.google.com with SMTP id x4so12216926wru.7 for ; Thu, 13 Jan 2022 12:24:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=1wU4dSRktrLEafep13DTS2esTRe5anY+Dh8F4MzMRZc=; b=QEc/LEFExaw9nU2/qGIEMfOKRL0M/h6UW/9/81W2KCLy2k17+rJH9De13QpP7wOvut +BZaNSBrTFJUNx966GZTIVzd+vgy6gYDMkf6lT8tHRn0Aj7BbmLszKUe0F6LSO8nOTkM TKShpqsOQh1RbHLDyjFnv88ngGtdgJWSRjt2JV0LATvazIJVac52nwYRO7q3TyQ4JF0r 7u7ov1eUjdxnqHQw+cDCka4uAIeHZzt5gFMFYUA1RenvbigcfYMVHpI5PZ+mLQQAU4jn f1xpAJREbPGLfGD8vX3r/Q6np6Vs3AhmNM+GAYRWM6dmwBdn5I92Dko8fl7b8L4LN7Rk 49ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=1wU4dSRktrLEafep13DTS2esTRe5anY+Dh8F4MzMRZc=; b=10G4tAKOVG6Wjcl1hkdbLG8YXQmPVi9RenGKIONUlVSfiMvpxQbVVNyEMvCYlM7QoT JUItDKmk57BUaGVLegmUGzQIpjdMxc8JIQjSMG0y9ntuaI82hR/DJox359pP6dDuqswb lSIcjoW1ANhI0nzURSBN/BqxW3mDGyQcxxZt3IR42L7UCIBp/QRjT6SdhdO1a3EI9e8L yfE31d8rnIt+HED70QpswqpGMBKAefcrKCfyTYRiBk5kq8hBdiIhQ/LOMLZEP0q6B9c6 YmrBHVwVqsUtWyNQV1SpapWOjRwlbsWTJ5ftOtNbYXHnPXZiaAHgfW693a4UlMfEfk5C gG0A== X-Gm-Message-State: AOAM532bSORA1nl3Eiu+rmxCS78UAMVermHl/UUQCvL+Q5eVtyMsUWhY ETbtoEPIi18Wb1UF47//hrZgwuZRZGlVvQAh2fc= X-Google-Smtp-Source: ABdhPJwjG2Eik5aT6OflalaIOxUmKebKLMArWWJIr9yHJF2ChA0/W1hiLnZNXXttSGnr95LgXclP6G9pknKSCjt7pMo= X-Received: by 2002:a05:6000:156d:: with SMTP id 13mr5311989wrz.33.1642105487950; Thu, 13 Jan 2022 12:24:47 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Csaba Raduly Date: Thu, 13 Jan 2022 21:24:36 +0100 Message-ID: Subject: Re: -Wsign-conversion flag in gcc in cygwin. To: Amit Cc: cygwin list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Jan 2022 20:24:51 -0000 On Thu, 13 Jan 2022 at 15:34, Amit wrote: > > Hi, > > When I compile "long x =3D strlen("abcde")" on a linux system with the > following gcc flags -Wall -Wconversion, I get the following warning: ... > warning: conversion to =E2=80=98long int=E2=80=99 from =E2=80=98size_t=E2= =80=99 may change the sign of the result [-Wsign-conversion] Which Linux system? I get the same result on Ubuntu (WSL) $ cat conversion-warning.c #include int main() { long x =3D strlen("meow"); // compile with -Wall -Wconversion return x; } $ gcc-10 -Wall -Wconversion conversion-warning.c conversion-warning.c: In function =E2=80=98main=E2=80=99: conversion-warning.c:6:12: warning: conversion from =E2=80=98long int=E2=80= =99 to =E2=80=98int=E2=80=99 may change value [-Wconversion] 6 | return x; | ^ (Note, this is not the sign conversion from size_t to (signed) long, but the truncation from long to int) $ gcc-10 --version gcc-10 (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ gcc-10 -dumpmachine x86_64-linux-gnu Csaba --=20 You can get very substantial performance improvements by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler So if you're looking for a completely portable, 100% standards-conformant w= ay to get the wrong information: this is what you want. - Scott Meyers (C++TDa= WYK)