[Bug 295431] CURRENT compiler miscompiles lang/mit-scheme

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 22 May 2026 00:52:06 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295431

--- Comment #10 from John F. Carr <jfc@mit.edu> ---
Now I think llvm20+ is technically correct but surprising.

The other half of the problem is a change in the front end in llvm20, adding
no-unsigned-wrap to this line

  SCHEME_OBJECT * scan_to = (STACK_LOC (-n_words));

The STACK_LOC macro expands to

  stack_pointer + (-n_words)

The index n_words is an unsigned type, so -n_words is a very large number and
the addition wraps around the end of the address space.  Guessing now, the
compiler sees addr+0xffffffffffffffff, guaranteed not to overflow, and deduces
that addr must be 0.

One is supposed to write

  stack_pointer - n_words

or make n_words a signed type.

This comment is based on reading cppreference, not the standard itself.

-- 
You are receiving this mail because:
You are the assignee for the bug.