From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#61730: 30.0.50; Compiler warnings for delq and delete Date: Fri, 24 Feb 2023 14:43:34 +0100 Message-ID: <670D8E4A-333D-4E2D-97CC-86728965989D@gmail.com> References: <87ilfsisje.fsf@web.de> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.14\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8648"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61730@debbugs.gnu.org, Stefan Monnier To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Feb 24 14:44:36 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pVYNI-00024j-5g for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Feb 2023 14:44:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVYMn-0002D1-8Z; Fri, 24 Feb 2023 08:44:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVYMk-0002Bz-W5 for bug-gnu-emacs@gnu.org; Fri, 24 Feb 2023 08:44:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVYMk-0006Nf-OP for bug-gnu-emacs@gnu.org; Fri, 24 Feb 2023 08:44:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pVYMk-0006JM-EJ for bug-gnu-emacs@gnu.org; Fri, 24 Feb 2023 08:44:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87ilfsisje.fsf@web.de> Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 24 Feb 2023 13:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61730 X-GNU-PR-Package: emacs Original-Received: via spool by 61730-submit@debbugs.gnu.org id=B61730.167724622424202 (code B ref 61730); Fri, 24 Feb 2023 13:44:02 +0000 Original-Received: (at 61730) by debbugs.gnu.org; 24 Feb 2023 13:43:44 +0000 Original-Received: from localhost ([127.0.0.1]:36319 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVYMS-0006II-6A for submit@debbugs.gnu.org; Fri, 24 Feb 2023 08:43:44 -0500 Original-Received: from mail-lj1-f181.google.com ([209.85.208.181]:42574) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVYMP-0006I2-Va for 61730@debbugs.gnu.org; Fri, 24 Feb 2023 08:43:43 -0500 Original-Received: by mail-lj1-f181.google.com with SMTP id e9so14168547ljn.9 for <61730@debbugs.gnu.org>; Fri, 24 Feb 2023 05:43:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=AVJhFIepaD10As4d+SSTHaDWEhTzVshaBTmIwPwRZoY=; b=P0yeEIaViOseU8CKHnSWgiORtZCgc2ma5LdUDHXTJbOg7yEuWCBKBVxkUVbLbNFcNZ /3giDLJxv1BdIOWH4PzaCtDtfIIsGOIwJJbOKsXJKL+qJovAweY4VWJqtAp2pIzcHAqZ hUqM76xEGn4NZYjz54sbTJGYBxkp7MC7TDG25BwBdnHw+AXDxBzryoQPEbQOQNuOE8ED JpBSCbvKAwszDjL2BJlKeg343HQQOqtwGEXbU52jv6jnQqDaJh1Q4LraZy+jcKUOl6Bn rhVdkE6fVAmbw/C8ZPd/uIeqOOUo94pLj9yyp0xo+Ng1TFrotmfoDdYCK+KsywAcTED8 41tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AVJhFIepaD10As4d+SSTHaDWEhTzVshaBTmIwPwRZoY=; b=oUStKWkItPQG0DJ0ybwmJqO2hGdI/mZPLqj4nJW+/+01H6+42m1xowutHbFmUYy2Mg DBK9mU5l3DwzUgfja6PqNR4JDOWps3vlk9wWtu5xS9nVLrbPlwRIUqJ08lRMNunHnAey Ml53nUYVjs5n6ay/VuT12bt/Fou1PmEd0z0Io6R15Od381LL6128HyICpcE4RLmMqJ6g xtPkqUQ4wJ609BKxU9htlKMizK1njvhSkIFj6H+s7ufK2R/+SzAz4Clcytq8n2H37lc+ gN7bhxA+cIF/ezIDHZlC6FclJuqUha+BPj3SfSqoKFTuCRFUVENsc8zNKdYjX7v30oqO XGFg== X-Gm-Message-State: AO0yUKVoOZKfUG4PYpMFf2F5HnfEGb3OG966D6Z6nFoNMMxlTk5AAyL3 jWiaW+cxHKmdRqGZGo95wb8= X-Google-Smtp-Source: AK7set92kpy6/DF96MBZ/o8ZaVqNCEje3ygaurlxAR+A3dhSxAiFzlXFsL4x+i+etw3Wf0XYEALZlA== X-Received: by 2002:a2e:a227:0:b0:293:40ce:b08e with SMTP id i7-20020a2ea227000000b0029340ceb08emr6624134ljm.16.1677246215768; Fri, 24 Feb 2023 05:43:35 -0800 (PST) Original-Received: from smtpclient.apple (c188-150-171-209.bredband.tele2.se. [188.150.171.209]) by smtp.gmail.com with ESMTPSA id s25-20020a2e2c19000000b002935006e487sm1019966ljs.122.2023.02.24.05.43.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2023 05:43:35 -0800 (PST) X-Mailer: Apple Mail (2.3654.120.0.1.14) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:256594 Archived-At: > I think we should add compiler warnings You rang? > for `delete' and `delq' function > calls whose return values are unused. Let's experiment: warning about for-effect calls to mapcar mapcan mapconcat delq delete delete-dups delete-consecutive-dups cl-delete cl-delete-if cl-delete-if-not cl-delete-duplicates sort results in 34 such calls found on master, most of them about `delq` and = `delete`, but `delete-dups`, `cl-delete`, `mapconcat` and `sort` are = also represented. Some of these are no doubt safe, a few of them knowingly so, but it's = definitely not obvious from a quick look at the code. It's poor style in = any case. Thus such a warning definitely falls on the beneficial side. Let's do = it. > I think the warnings could be added in a similar way as the "mapcar > called for effect" warnings work. That's probably the best place to start (although we prefer warnings to = be emitted by the front-end and not in codegen). We may want to change the warning text from "called for effect" because = it's written from the perspective of the compiler; the programmer thinks = of it as 'not using the return value'. For that matter, `with-suppressed-warnings` doesn't work for suppressing = this warning very well; we may want to do something about that. This is = true for the existing `mapcar` warning as well. > Adding the same kind of warning for `remq' and `remove' would probably > also be useful. This will probably not occur that often but it still > would be useful I think. The compiler should already warn about those two since they are declared = side-effect-free. Unless somehow `byte-compile-delete-errors` is set = during compilation, which can happen if the code messes about with = (optimise (safety ...)) -- it's a bit unfortunate. Please tell us if you = observe anomalies in this regard.