From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.4 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 4C6E21F4B4 for ; Sun, 3 Jan 2021 01:50:02 +0000 (UTC) Received: from localhost ([::1]:33320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kvsWu-0003mP-Ui for normalperson@yhbt.net; Sat, 02 Jan 2021 20:50:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kvsWk-0003lI-F8 for bug-gnulib@gnu.org; Sat, 02 Jan 2021 20:49:52 -0500 Received: from mo4-p00-ob.smtp.rzone.de ([85.215.255.20]:14730) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kvsWh-0000Gc-He for bug-gnulib@gnu.org; Sat, 02 Jan 2021 20:49:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1609638584; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:From: Subject:Sender; bh=VScfj4aNEYi+sbSLfkv3quICBgAjyekPlOpLNJaXMlk=; b=YZDnJ4WiBR7Zwf+o8Wf/1Nre6BJ4KEfJX4iCyrBOZR378en90Eh0ksXQHpS1jWrYng 4dEjZeMvnWZyJGxYeuX9OtoETgZtGfy257XfwVX8yyO9Z/0vBe4u3w7UKjDCQseNrPYi IakiTU59oHRXorghpt+Z4f56EwUp/QolVCK+80lNRe7MbKfWeby0ZT6RAdHsMCkfTPc3 Kf5z0l4HRLCA3A3UasZKLK8lffGn9mR1oyVE23cBuSrI3diIv8RDfX6mTzgyfiPN15xa KsFytIVklPgg28lOfjlNiEvjgvZkP5XHzPbSdRlfPxB7fcTeBWPZ99N2iS4Tksu75l3J 5gFg== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOH6f3z/s=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 47.10.7 DYNA|AUTH) with ESMTPSA id e012d5x031neaPv (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Sun, 3 Jan 2021 02:49:40 +0100 (CET) From: Bruno Haible To: bug-gnulib@gnu.org Subject: Re: vasnprintf.c vs GCC11's -Wanalyzer-null-argument (and glibc-2.31) Date: Sun, 03 Jan 2021 02:49:39 +0100 Message-ID: <2624561.TfKlLiq1dV@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-197-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Received-SPF: none client-ip=85.215.255.20; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-1.118, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jim Meyering Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Hi Jim, > I built latest gcc from git and then attempted to build things with it. > I noticed this new warning while trying to build diffutils, but > haven't had time to address: The vast majority of -Wanalyzer* warnings that we have seen so far were fal= se alarms [1]. This one is a false alarm as well. The compiler is complaining that in vasnprintf.c:1962 if (cp !=3D dp->dir_start) //= <=3D=3D 1951 { size_t n =3D dp->dir_start - cp; //= <=3D=3D 1953 size_t augmented_length =3D xsum (length, n); //= <=3D=3D 1954 ENSURE_ALLOCATION (augmented_length); // <= =3D=3D 1956 /* This copies a piece of FCHAR_T[] into a DCHAR_T[]. Here we need that the format string contains only ASCII characters if FCHAR_T and DCHAR_T are not the same type. */ if (sizeof (FCHAR_T) =3D=3D sizeof (DCHAR_T)) { DCHAR_CPY (result + length, (const DCHAR_T *) cp, n); // <= =3D=3D 1962 DCHAR_CPY =3D memcpy could be invoked with result =3D NULL. But when you lo= ok at all assignments to 'result', result is only assigned NULL in line 1916, and here allocated =3D 0. By the logic of the ENSURE_ALLOCATION macro, 'res= ult' is only assigned a new value when 'allocated' is, and vice versa. Now, since in line 1953 n > 0 (due to line 1951), in line 1954 augmented_le= ngth is also > 0 (by the definition of xsum), hence ENSURE_ALLOCATION in line 19= 56 gets invoked with a positive argument, thus in line 1927 if ((needed) > allocated) must evaluate to true. The compiler's logic did not see this; it proposed a code path where in line 1927 the condition evaluates to false =E2=80=94 w= hich cannot happen. So, in the current state, looking at -fanalyzer / -Wanalyzer outputs is still a waste of time. I don't want to modify the source code to silence false alarms from this (yet immature) tool. Bruno [1] https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00118.html