DEFCFUN and unsigned-long-long behaving badly on 64-bit Allegro CL

Bug #914500 reported by Luís Oliveira
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
CFFI
Triaged
Medium
Luís Oliveira

Bug Description

Bug report sent to Franz.

(in-package :cl-user)

#||

#include <limits.h>

unsigned long long ullong(unsigned long long n)
{
    printf("ullong(%llu)\n", n);
    return n == ULLONG_MAX ? n : 42;
}

||#

(ff:def-foreign-call (ullong "ullong")
    ((n :unsigned-nat (unsigned-byte 64)))
  :returning (:unsigned-nat (unsigned-byte 64))
  :call-direct t ; setting this to nil fixes the symptoms.
  :arg-checking nil
  :strings-convert nil)

(defun test-ullong ()
  (ullong (1- (expt 2 64))))

;; CL-USER> (ullong (1- (expt 2 64)))
;; ullong(18446744073709551615)
;; 18446744073709551615 ; OK
;;
;; But when :call-direct kicks in:
;; CL-USER> (test-ullong)
;; ullong(18446744073709551615) ; argument was fine
;; -1 ; but return value is wrong

Luís Oliveira (luismbo)
tags: added: allegro implementation-bug
Luís Oliveira (luismbo)
description: updated
Luís Oliveira (luismbo)
Changed in cffi:
importance: Undecided → Medium
status: New → Triaged
assignee: nobody → Luís Oliveira (luismbo)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.