News for hackers. Stuff that matters.
Re:Out-of-bounds read and write in the glibc's qsort() by koito17 on Monday February 05, 2024 @06:17PM (#39268554)
Depending on what you allow in predicate types, you end up making type inference (and/or type checking) an undecidable problem.

In Common Lisp, you can write

  (deftype element () `(integer 100 1000))
and in this case, a "smart" compiler like SBCL will be able to infer the bounds of (the element x), but for more complex predicates, like

  (deftype even-element () 
    `(and (integer 100 1000)
          (satisfies evenp)))
I highly doubt there is a single CL compiler out there that'd be able to e.g. optimize (logand 1 (the even-element x)) into the constant 0. Thus declaring types like this -- in Common Lisp at least -- is only really useful for documenting code and run-time validation.
Re:Out-of-bounds read and write in the glibc's qsort() by moonchild on Monday February 05, 2024 @07:15PM (#39269063)
Extant cl compilers are quite primitive. Well known and uncomplicated analyses exist that can cope with this; e.g. in llvm https://godbolt.org/z/nadbG5zGs