Skip to content
This repository was archived by the owner on Jun 16, 2021. It is now read-only.
This repository was archived by the owner on Jun 16, 2021. It is now read-only.

size_t isnt usize and usize isnt size_t (at least on Macos) #68

@uucidl

Description

@uucidl

See repro at: uucidl@a96b036

ion -os osx -arch x64 bugs && \
  cc out_bugs.c -o bugs.elf && \
  ./bugs.elf ; echo "rc:$?"

Expected:

Processed 101 symbols in 2 packages
Generated out_bugs.c
rc:42

Got:

Processed 101 symbols in 2 packages
Generated out_bugs.c
<foo>/Desktop/bitwise/ion/bugs/size_bug.ion:10:25: warning:
      incompatible pointer types passing 'ullong *' (aka 'unsigned long long *')
      to parameter of type 'size_t *' (aka 'unsigned long *')
      [-Wincompatible-pointer-types]
    fetch_value(&(num), &(num_size));
                        ^~~~~~~~~~~
<foo>/Desktop/bitwise/ion/bugs/size_bug.h:3:41: note: passing argument
      to parameter 'dest_size_ptr' here
int fetch_value(void* dest_ptr, size_t* dest_size_ptr);
                                        ^
1 warning generated.
rc:42

I would have expected C apis expressed in terms of size_t to be
exposed in ion via usize. It appears that on Macos at least:

cc -E out_bugs.c | grep -E '(typedef.* uint64_t;|typedef.* size_t;)'
typedef unsigned long long uint64_t;
typedef long unsigned int size_t;

Since usize is defined as uint64, we see that these types differ.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions