[LLVMbugs] [Bug 9242] New: Length parameters for the C API should be 'size_t', not 'unsigned'.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Feb 17 17:19:49 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=9242

           Summary: Length parameters for the C API should be 'size_t',
                    not 'unsigned'.
           Product: libraries
           Version: 2.8
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Core LLVM classes
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: blood.of.life at gmail.com
                CC: llvmbugs at cs.uiuc.edu


A lot of the C wrapper functions take a pointer and a length when expecting a
list of things. For instance, the signature of `LLVMBuildCall`:

    ... LLVMBuildCall(..., LLVMValueRef* Args, unsigned NumArgs,...)

Usually, `unsigned i` declares i as 32 bit unsigned integer. On 32 bit
architectures, this can adequately index a pointer and all is well. On 64 bit
architectures, however, a 64 bit unsigned integer is required to do this. The
size_t type (in cstdint) does this job. In the above example, `NumArgs` should
be declared as `size_t NumArgs`.

Incidentally, this bugs me as I'm using the C API from D. D arrays have a
pointer and a length -- the length is declared as size_t. when using the above,
I can create a D array of LLVMValueRefs and then pass it like

LLVMBuildCall(..., args.ptr, args.length,...)

Except if I'm building for 64 bit, I have to explicitly cast the length to uint
to call LLVM.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list