Skip to content

cgen error with arrays of empty interface literal #24442

Description

@einar-hjortdal

Describe the bug

error: cannot convert 'struct string' to 'void *'

Reproduction Steps

module main

import arrays

interface Value {}

struct CreateRegionData {
	name          string
	currency_code string
	tax_rate      f32
	tax_code      string @[omitempty]
	countries     []string
	includes_tax  bool @[omitempty]
}

fn main() {
	rd := CreateRegionData{}
	id := 'bro'
	the_array := [Value(id), rd.name]
	println(the_array)
}

Expected Behavior

No cgen error

Current Behavior

cgen error

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.10 47f8f34

Environment details (OS name and version, etc.)

v doctor
|V full version      |V 0.4.10 537605a.47f8f34
|:-------------------|:-------------------
|OS                  |linux, "openmamba release 2024.6 for x86_64 (rolling)"
|Processor           |8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
|Memory              |10.37GB/31.16GB
|                    |
|V executable        |/home/einar/.local/lib64/v/v
|V last modified time|2025-05-09 13:43:59
|                    |
|V home dir          |OK, value: /home/einar/.local/lib64/v
|VMODULES            |OK, value: /home/einar/.vmodules
|VTMP                |OK, value: /tmp/v_1000
|Current working dir |OK, value: /home/einar/Documents/projects/vlang/active/peony
|                    |
|Git version         |git version 2.49.0
|V git status        |weekly.2025.17-69-g47f8f347
|.git/config present |true
|                    |
|cc version          |cc (GCC) 14.2.1 20240909
|gcc version         |gcc (GCC) 14.2.1 20240909
|clang version       |N/A
|tcc version         |tcc version 0.9.28rc 2024-07-31 HEAD@1cee0908 (x86_64 Linux)
|tcc git status      |thirdparty-linux-amd64 0134e9b9
|emcc version        |N/A
|glibc version       |ldd (GNU libc) 2.41

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.Status: Has WorkaroundThis issue has workaround.Unit: cgenBugs/feature requests, that are related to the default C generating backend.

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions