From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id 033C639450ED for ; Fri, 27 Mar 2020 09:02:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 033C639450ED Received: by mail-il1-x132.google.com with SMTP id n13so701815ilm.5 for ; Fri, 27 Mar 2020 02:02:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=THfgeSmP20wgqE9+rguK5KRSvEnEvYfgdI8ynG4wnAY=; b=EqRIstRCslhK1UyouQrYzyB1bAggUc0+9eBg8+fHDEuEYIPt+LnbLDwuT/hpIAgOd2 Sx7zd9/j7Ta+K9ee2ixJXOjD+7pcHVu3WtkT9K3it3bQ01TkZhd3gbhIGf3fC19PoxRT RlxI5wapBEMYJVS5RWP99qvh/XiS9eNZK9GggD2PdBiGg43GrP+8JjKEMwVLTx5yOFuT X+SaznBCQIR2yUHte9XkkkO2qRiJ4lDjrPjb9d2zHL3v2X7EKhqvtALOqKO6mL2MYDFI CgcI+d+nksaPIbqHD4p6kpIYdMMBKacY0dCWsf0mOHBw738CJeVJIgJRTAN2EaZlW9nr 3V1A== X-Gm-Message-State: ANhLgQ2X9s6kJkDAYfUOcFPNLVjsaIDQExSfhdL2FNmPw2RIA2rLkt7j oTiv6lclaEdOG/eBw4jj0P69ebmw1tGDHTO+eMs= X-Google-Smtp-Source: ADFU+vtAhKUEnrJPMlR5DAx92m2tkls5Byn1KkAN5ihkWIbGHQ5Tinrqz/WukkCwty2fzB2TsB/Jet+iY+oe+cM34oE= X-Received: by 2002:a92:5ccd:: with SMTP id d74mr11969523ilg.59.1585299725415; Fri, 27 Mar 2020 02:02:05 -0700 (PDT) MIME-Version: 1.0 References: <20200325223732.74127385E01C@sourceware.org> In-Reply-To: <20200325223732.74127385E01C@sourceware.org> From: Jonathan Wakely Date: Fri, 27 Mar 2020 09:01:54 +0000 Message-ID: Subject: Re: GSoC Static Analysis To: Andrew Briand Cc: "gcc@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.9 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Mar 2020 09:02:07 -0000 On Wed, 25 Mar 2020 at 22:38, Andrew Briand wrote: > > Hello, > > I am an undergrad interested in extending GCC=E2=80=99s static analysis p= ass for GSoC 2020. In particular, I=E2=80=99m interested in adding C++ supp= ort. > > The selected project ideas list mentions adding new/delete checking and e= xception checking. The features that immediately come to my mind would be c= hecking for undeleted allocations, mixing delete and delete[], double delet= ion (it seems the current static analyzer already checks for double free), = and uncaught exceptions. I'm not sure reporting about uncaught exceptions is useful, except in the (unlikely) case where the entire program is visible to the compiler, or maybe as an extension of the -Wterminate warning. Exceptions are *supposed* to be uncaught in most code, so they propagate to a layer that can actually do something about the error. Some other ideas for C++ code could be: - Locking a mutex twice, or locking it and not unlocking it in the same sco= pe. - Locking and unlocking a mutex around a region with no side effects (i.e. no I/O, no volatile read/writes, no atomic operations on non-local variables). - Using a shared_ptr where there's only a single owner so unique_ptr would = work. - Returning a reference/pointer to a local variable through another function (which the current -Wreturn-local-addr warning can't diagnose) e.g. int& f(int& i) { return i; } int& g() { int i =3D 0; return f(i); }