unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattias.engdegard@gmail.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: 61730@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#61730: 30.0.50; Compiler warnings for delq and delete
Date: Fri, 24 Feb 2023 14:43:34 +0100	[thread overview]
Message-ID: <670D8E4A-333D-4E2D-97CC-86728965989D@gmail.com> (raw)
In-Reply-To: <87ilfsisje.fsf@web.de>

> 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.






  parent reply	other threads:[~2023-02-24 13:43 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-23 10:29 bug#61730: 30.0.50; Compiler warnings for delq and delete Michael Heerdegen
2023-02-24  3:59 ` Richard Stallman
2023-02-24 13:43 ` Mattias Engdegård [this message]
2023-02-24 13:56   ` Eli Zaretskii
2023-02-24 15:11     ` Michael Heerdegen
2023-02-24 15:29       ` Eli Zaretskii
2023-02-24 15:45         ` Michael Heerdegen
2023-02-24 15:48           ` Eli Zaretskii
2023-02-24 16:17             ` Michael Heerdegen
2023-02-24 16:45               ` Michael Heerdegen
2023-02-24 19:33                 ` Mattias Engdegård
2023-02-24 20:20                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-25  9:40                     ` Mattias Engdegård
2023-02-25  4:15       ` Richard Stallman
2023-02-25  8:11         ` Eli Zaretskii
2023-02-25 12:34           ` Michael Heerdegen
2023-02-25 13:25             ` Eli Zaretskii
2023-02-25 15:09               ` Michael Heerdegen
2023-02-25 15:29                 ` Michael Heerdegen
2023-02-25 15:48                 ` Eli Zaretskii
2023-02-27  3:22                   ` Richard Stallman
2023-02-27 10:37                     ` Michael Heerdegen
2023-02-27 11:37                     ` Eli Zaretskii
2023-02-27  3:24           ` Richard Stallman
2023-02-27 11:44             ` Eli Zaretskii
2023-02-24 15:52   ` Mattias Engdegård
2023-02-24 16:37     ` Michael Heerdegen
2023-04-09 16:41 ` Mattias Engdegård
2023-05-01 16:06   ` Mattias Engdegård
2023-05-20  1:57     ` Michael Heerdegen
2023-05-20  9:14       ` Mattias Engdegård
2023-05-21  0:56         ` Michael Heerdegen
2023-05-21  3:01           ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-21  3:57             ` Michael Heerdegen
2023-05-21  5:55               ` Eli Zaretskii
2023-05-21  8:42               ` Mattias Engdegård
2023-05-31 14:38         ` Mattias Engdegård
2023-06-01  0:48           ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=670D8E4A-333D-4E2D-97CC-86728965989D@gmail.com \
    --to=mattias.engdegard@gmail.com \
    --cc=61730@debbugs.gnu.org \
    --cc=michael_heerdegen@web.de \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).