Skip to content

u64 from C lost high part #14783

@kbkpbot

Description

@kbkpbot

OS: linux, Ubuntu 22.04 LTS (WSL 2)
Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz
CC version: cc (Ubuntu 11.2.0-19ubuntu1) 11.2.0

getwd: /home/lastgod/test/v
vmodules: /home/lastgod/.vmodules
vroot: /home/lastgod/github/lang/v
vexe: /home/lastgod/github/lang/v/v
vexe mtime: 2022-06-19 00:09:12
is vroot writable: true
is vmodules writable: true
V full version: V 0.2.4 e031096

Git version: git version 2.34.1
Git vroot status: weekly.2022.24-27-ge0310964
.git/config present: true
thirdparty/tcc status: thirdparty-linux-amd64 827f7452

What did you do?
Call C function which return unsigned long long, will return a signed extend 64 bit value

bug_u64.c

unsigned long long BugReturnU64()
{
	return 0xA5A5A5A5A5A5A5A5;
}

bug.v

#flag @VMODROOT/bug_u64.o

fn C.BugReturnU64() u64

fn main() {
	bugval := C.BugReturnU64()
	println('bugval = ${bugval : 016X}')
}

What did you expect to see?

bugval = A5A5A5A5A5A5A5A5

What did you see instead?

bugval = FFFFFFFFA5A5A5A5

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions