Skip to content

cgen error for pub const fixed_sized_comptime_array_const = $if amd64 { [1,2] } $else { [0] } #25691

Description

@spytheman
V version: V 0.4.12 fdf28bb, press to see full `v doctor` output
V full version V 0.4.12 393d5b9.fdf28bb
OS linux, Ubuntu 20.04.6 LTS
Processor 4 cpus, 64bit, little endian, Intel(R) Core(TM) i3-3225 CPU @ 3.30GHz
Memory 3.56GB/15.05GB
V executable /home/delian/v/v
V last modified time 2025-11-08 06:53:02
V home dir OK, value: /home/delian/v
VMODULES OK, value: /home/delian/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/delian/v
env VFLAGS "-no-parallel"
Git version git version 2.50.0
V git status weekly.2025.45-25-gfdf28bb6
.git/config present true
cc version cc (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0
gcc version gcc (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0
clang version Ubuntu clang version 18.1.8 (11~20.04.2)
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
emcc version N/A
glibc version ldd (Ubuntu GLIBC 2.31-0ubuntu9.18) 2.31

What did you do?
./v -g -o vdbg cmd/v && ./vdbg /home/delian/code/misc/2025_11_08__08/x.v && /home/delian/code/misc/2025_11_08__08/x

pub const fixed_sized_comptime_array_const = $if amd64 {
     [u8(0x01), 0x02]!
} $else $if i386 {
     [u8(0x01), 0x02, 0x03]!
} $else {
	 [u8(0)]!
}
println(fixed_sized_comptime_array_const)

What did you see?

================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/x.01K9H3YKZM2SWJYKAWHYGET8V2.tmp.c:5164: error: lvalue expected
=================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).

What did you expect to see?

a compiled program

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.

Metadata

Metadata

Assignees

Labels

BugThis tag is applied to issues which reports bugs.Unit: CompilerBugs/feature requests, that are related to the V compiler in general.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