GNU bug report logs - #47391
27.2; static list return from function and nconc

Previous Next

Package: emacs;

Reported by: Rajeev Narang <rajeev.jnk <at> sivalik.com>

Date: Thu, 25 Mar 2021 15:21:03 UTC

Severity: normal

Tags: fixed

Found in version 27.2

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Philipp Stephani <p.stephani2 <at> gmail.com>
Cc: Rajeev Narang <rajeev.jnk <at> sivalik.com>, 47391 <at> debbugs.gnu.org, Emacs developers <emacs-devel <at> gnu.org>
Subject: bug#47391: 27.2; static list return from function and nconc
Date: Thu, 25 Mar 2021 11:43:20 -0400
>> (defun fn () '(1 2))
>>
>> (nconc (fn) '(3))
>> -> (1 2 3)
>
> This is undefined behavior/unsupported. The value that (fn) evaluates
> to is immutable, but nconc mutates it.
>
>>
>> (nconc (fn) '(3))
>> -> (1 2 3 3) ? should be (1 2 3)
>>
>> If this is not a bug, then hfy-invisible, hfy-face-to-style-i may need to be fixed.
>
> If they use this pattern, then they should indeed be fixed.

Note that in the code above, we usually consider that the bug is not in
`fn` but in the use of `nconc` on a list which the code doesn't know can
safely be mutated (it should hence use `append` instead).


        Stefan





This bug report was last modified 4 years and 53 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.