Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C compilation error when accessing an element in a multi-dimensional array of optionals #23708

Open
jfcode4 opened this issue Feb 13, 2025 · 1 comment
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor.

Comments

@jfcode4
Copy link

jfcode4 commented Feb 13, 2025

V version: V 0.4.9 eecaa64, press to see full `v doctor` output
V full version V 0.4.9 eecaa64
OS linux, Linux version 6.12.11-200.fc41.x86_64 (mockbuild@8c05b49e2e66460390f7ce4d04d4f464) (gcc (GCC) 14.2.1 20250110 (Red Hat 14.2.1-7), GNU ld version 2.43.1-5.fc41) #1 SMP PREEMPT_DYNAMIC Fri Jan 24 04:59:58 UTC 2025
Processor 12 cpus, 64bit, little endian, AMD Ryzen 5 1600X Six-Core Processor
Memory 1.83GB/7.67GB
V executable /home/jacob/.local/v/v
V last modified time 2025-02-05 08:29:54
V home dir OK, value: /home/jacob/.local/v
VMODULES OK, value: /home/jacob/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/jacob/code/v/chess
Git version git version 2.48.1
V git status Error: fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
.git/config present false
cc version cc (GCC) 14.2.1 20250110 (Red Hat 14.2.1-7)
gcc version gcc (GCC) 14.2.1 20250110 (Red Hat 14.2.1-7)
clang version clang version 19.1.7 (Fedora 19.1.7-1.fc41)
tcc version tcc version 0.9.28rc 2024-07-31 HEAD@1cee0908 (x86_64 Linux)
tcc git status N/A
emcc version N/A
glibc version ldd (GNU libc) 2.40

What did you do?
v bug.v

struct Test{
	board   [8][8]?Piece
}
struct Piece{
	white   bool
}
fn main() {
	t := Test{}
	println(t.board[1][2]) // error happens here
}

What did you see?

================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/bug.01JKZECDNZ1V3W4D7F3XZ7HFNX.tmp.c:1050: error: ';' expected (got "Array_fixed_Array_fixed__option_main__Piece_8_8")
=================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

What did you expect to see?

no C compilation error

It looks like accessing an element in a multi-dimensional array of optionals causes this error. The error doesn't happen on 1-dimensional arrays or even multi-dimensional slices.

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.

Copy link

Connected to Huly®: V_0.6-22127

@JalonSolov JalonSolov added Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. labels Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor.
Projects
None yet
Development

No branches or pull requests

2 participants