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

cgen error for fixed array of fixed arrays in const #23565

Closed
gechandesu opened this issue Jan 23, 2025 · 1 comment · Fixed by #23572
Closed

cgen error for fixed array of fixed arrays in const #23565

gechandesu opened this issue Jan 23, 2025 · 1 comment · Fixed by #23572
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@gechandesu
Copy link
Contributor

gechandesu commented Jan 23, 2025

Describe the bug

Fixed array of fixed arrays in const turn to an error if the array element is another const.

This works fine:

const f = [u8(0), 1, 2]!

const ff = [[u8(1), 2, 3]!, [u8(5), 4, 3]!, f]

fn main() {
	println(ff)
}

Reproduction Steps

~ $ v vet fixed_arr_const.vv
fixed_arr_const.vv:3: notice: Use a fixed array instead of a dynamic one

So with this...

const f = [u8(0), 1, 2]!

const ff = [[u8(1), 2, 3]!, [u8(5), 4, 3]!, f]!

fn main() {
	println(ff)
}

C compilation fails.

Remving f from ff array solves the problem.

Expected Behavior

Successful compilation or V checker error?

Current Behavior

~ $ v run fixed_arr_const.vv
================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/fixed_arr_const.01JJAEMTRDKZ1HYHKC8MJZJRMS.tmp.c:1573: error: initializer element is not constant
=================================================================
(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 .

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.9 da5bb68

Environment details (OS name and version, etc.)

v doctor

V full version V 0.4.9 5ec9bb5.da5bb68
OS linux, Linux version 6.6.8-arch1-1 (linux@archlinux) (gcc (GCC) 13.2.1 20230801, GNU ld (GNU Binutils) 2.41.0) #1 SMP PREEMPT_DYNAMIC Thu, 21 Dec 2023 19:01:01 +0000
Processor 16 cpus, 64bit, little endian, 12th Gen Intel(R) Core(TM) i5-1240P
Memory 4.71GB/15.35GB
V executable /home/ge/.vlang/v
V last modified time 2025-01-23 20:38:12
V home dir OK, value: /home/ge/.vlang
VMODULES OK, value: /home/ge/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/ge
Git version git version 2.48.1
V git status weekly.2025.03-28-gda5bb68b
.git/config present true
cc version cc (GCC) 14.2.1 20240910
gcc version gcc (GCC) 14.2.1 20240910
clang version clang version 19.1.7
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.40

> [!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.
@gechandesu gechandesu added the Bug This tag is applied to issues which reports bugs. label Jan 23, 2025
Copy link

Connected to Huly®: V_0.6-21993

@felipensp felipensp added Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend. Unit: Checker Bugs/feature requests, that are related to the type checker. and removed Unit: cgen Bugs/feature requests, that are related to the default C generating backend. Unit: Checker Bugs/feature requests, that are related to the type checker. labels Jan 25, 2025
@felipensp felipensp self-assigned this Jan 25, 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. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants