Skip to content

literal value cannot used for call C.va_list func #23123

Closed
@kitech

Description

@kitech

Describe the bug

Code: https://play.vlang.io/p/409c8741ac

#include <stdarg.h>

@[typedef]
struct C.va_list {}
fn C.va_start(voidptr, voidptr)
fn C.va_end(voidptr)

fn C.vfprintf(&C.FILE, &char, C.va_list) int

fn t2(fmt voidptr, ...) {
	ap := C.va_list{}
	C.va_start(ap, fmt)
	C.vfprintf(C.stderr, fmt, ap)
	C.va_end(ap)
}

fn main() {
	a := 1
	b := 2.5
	t2(c'%s : %d : %.2f, %d, %c\n', c'foo', a, b, 42, `v`)
}

Reproduction Steps

vv

Expected Behavior

foo: 1: 2.5, 42, v

Current Behavior

Output:

code.v:20:48: error: expression cannot be passed as `voidptr`
   18 |     a := 1
   19 |     b := 2.5
   20 |     t2(c'%s : %d : %.2f, %d, %c\n', c'foo', a, b, 42, `v`)
      |                                                   ~~
   21 | }
Exited with error status 1

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.8 43e27d2

Environment details (OS name and version, etc.)

V full version: V 0.4.8 43e27d2
OS: linux, Debian GNU/Linux 12 (bookworm) (VM)
Processor: 2 cpus, 64bit, little endian, Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz

getwd: /home/admin/playground
vexe: /home/admin/v/v
vexe mtime: 2024-12-10 12:25:26

vroot: OK, value: /home/admin/v
VMODULES: OK, value: .vmodules
VTMP: OK, value: /tmp/v_0

Git version: git version 2.39.5
Git vroot status: Error: fatal: detected dubious ownership in repository at '/home/admin/v'
To add an exception for this directory, call:

	git config --global --add safe.directory /home/admin/v
.git/config present: true

CC version: cc (Debian 12.2.0-14) 12.2.0
emcc version: N/A
thirdparty/tcc status: Error: fatal: detected dubious ownership in repository at '/home/admin/v/thirdparty/tcc'
To add an exception for this directory, call:

	git config --global --add safe.directory /home/admin/v/thirdparty/tcc
 Error: fatal: detected dubious ownership in repository at '/home/admin/v/thirdparty/tcc'
To add an exception for this directory, call:

	git config --global --add safe.directory /home/admin/v/thirdparty/tcc

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Huly®: V_0.6-21560

Metadata

Metadata

Assignees

Labels

BugThis tag is applied to issues which reports bugs.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.Unit: CheckerBugs/feature requests, that are related to the type checker.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions