unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#46843: 28.0.50; [native-comp] (lambda (x) (if (equal x b) (eq x b) (error ""))) miscompiled
@ 2021-03-01  6:51 Pip Cet
  2021-03-01  8:08 ` Pip Cet
  2021-03-01  9:08 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 4+ messages in thread
From: Pip Cet @ 2021-03-01  6:51 UTC (permalink / raw)
  To: 46843

In *scratch*, evaluate

(funcall
 (let* ((lexical-binding t)
        (a (list 'a))
        (b (cons a a)))
   (native-compile
    `(lambda (x) (if (equal x ',b) (eq x ',b) (error "")))))
 '((a) a))

Expected result:

nil

Actual result:

t





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#46843: 28.0.50; [native-comp] (lambda (x) (if (equal x b) (eq x b) (error ""))) miscompiled
  2021-03-01  6:51 bug#46843: 28.0.50; [native-comp] (lambda (x) (if (equal x b) (eq x b) (error ""))) miscompiled Pip Cet
@ 2021-03-01  8:08 ` Pip Cet
  2021-03-01  9:08 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 4+ messages in thread
From: Pip Cet @ 2021-03-01  8:08 UTC (permalink / raw)
  To: 46843

On Mon, Mar 1, 2021 at 6:53 AM Pip Cet <pipcet@gmail.com> wrote:
>
> In *scratch*, evaluate
>
> (funcall
>  (let* ((lexical-binding t)
>         (a (list 'a))
>         (b (cons a a)))
>    (native-compile
>     `(lambda (x) (if (equal x ',b) (eq x ',b) (error "")))))
>  '((a) a))

The same issue applies to eql. However, I had to convince myself first
that there is valid and useful code that keeps track of the eq-uality
of eql floats. There is, because there might be an eq-based hash table
that uses them.

(funcall
 (let* ((canonical-one 1.0)
        (hash (make-hash-table :test 'eq)))
   (puthash canonical-one t hash)
   (let* ((is-canonical-one
           `(lambda (x) (if (eql x ,canonical-one) (eq x
,canonical-one) (error "")))))
     (setq is-canonical-one (native-compile is-canonical-one))
     `(lambda (x) (if (funcall ',is-canonical-one x) (cl-assert
(gethash x ',hash))))))
 1.0)

is miscompiled to code that causes an assertion violation when it
actually is correct code that verifies, in two different ways, that x
is eq to a canonical float representing 1.0.
Pip





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#46843: 28.0.50; [native-comp] (lambda (x) (if (equal x b) (eq x b) (error ""))) miscompiled
  2021-03-01  6:51 bug#46843: 28.0.50; [native-comp] (lambda (x) (if (equal x b) (eq x b) (error ""))) miscompiled Pip Cet
  2021-03-01  8:08 ` Pip Cet
@ 2021-03-01  9:08 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-03-01 17:26   ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 4+ messages in thread
From: Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-03-01  9:08 UTC (permalink / raw)
  To: Pip Cet; +Cc: 46843

Pip Cet <pipcet@gmail.com> writes:

> In *scratch*, evaluate
>
> (funcall
>  (let* ((lexical-binding t)
>         (a (list 'a))
>         (b (cons a a)))
>    (native-compile
>     `(lambda (x) (if (equal x ',b) (eq x ',b) (error "")))))
>  '((a) a))
>
> Expected result:
>
> nil
>
> Actual result:
>
> t

Thanks for reporting this, will come-up with a fix.

  Andrea





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#46843: 28.0.50; [native-comp] (lambda (x) (if (equal x b) (eq x b) (error ""))) miscompiled
  2021-03-01  9:08 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-03-01 17:26   ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 4+ messages in thread
From: Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-03-01 17:26 UTC (permalink / raw)
  To: 46843; +Cc: 46843-done, Pip Cet

Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@gnu.org> writes:

> Pip Cet <pipcet@gmail.com> writes:
>
>> In *scratch*, evaluate
>>
>> (funcall
>>  (let* ((lexical-binding t)
>>         (a (list 'a))
>>         (b (cons a a)))
>>    (native-compile
>>     `(lambda (x) (if (equal x ',b) (eq x ',b) (error "")))))
>>  '((a) a))
>>
>> Expected result:
>>
>> nil
>>
>> Actual result:
>>
>> t
>
> Thanks for reporting this, will come-up with a fix.

Right 3d014e1bf4 is fixing the wrong assumtion that `equal' `eql' can be
treated as `eq' in propagation as every immediate in the compilation
unit is hash consed.  Indeed this assumtion is wrong for more than one
reason.

Now under `equal' `eql' we propagate only fixnums and symbols values,
all the other kind of values are promoted to their respective types and
propagated as such.

The patch adds some tests for that too.

As the two reproducer are working here I'm closing this.

Thanks for reporting.

  Andrea





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-01 17:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01  6:51 bug#46843: 28.0.50; [native-comp] (lambda (x) (if (equal x b) (eq x b) (error ""))) miscompiled Pip Cet
2021-03-01  8:08 ` Pip Cet
2021-03-01  9:08 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-01 17:26   ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors

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