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 error when assigning generic fixed size array to a variable #19903

Closed
lv37 opened this issue Nov 16, 2023 · 10 comments · Fixed by #19916
Closed

C error when assigning generic fixed size array to a variable #19903

lv37 opened this issue Nov 16, 2023 · 10 comments · Fixed by #19916
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@lv37
Copy link
Contributor

lv37 commented Nov 16, 2023

Describe the bug

module main

fn init_type[T]() {
	_ := T{}
}

fn main() {
	init_type[[3]int]()
}

gives:

/tmp/v_1002/src.5677094858549572046.tmp.c:12624: error: '{' expected (got ";")

Reproduction Steps

Try compiling the above code

Expected Behavior

Compile successfully

Current Behavior

/tmp/v_1002/src.5677094858549572046.tmp.c:12624: error: '{' expected (got ";")

Possible Solution

No response

Additional Information/Context

Compiling with v -cc clang makes it compile successfully
Issue very similar to #19872

V version

V 0.4.3 e9258c2

Environment details (OS name and version, etc.)

V full version: V 0.4.3 4628fe7.e9258c2
OS: linux, Linux version 6.5.11-300.fc39.x86_64 (mockbuild@d23353abed4340e492bce6e111e27898) (gcc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4), GNU ld version 2.40-13.fc39) #1 SMP PREEMPT_DYNAMIC Wed Nov  8 22:37:57 UTC 2023
Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i5-4310U CPU @ 2.00GHz

getwd: /home/user/Projects/v-testing/webview
vexe: /home/user/.local/lib/v/v
vexe mtime: 2023-11-16 16:24:37

vroot: OK, value: /home/user/.local/lib/v
VMODULES: OK, value: /home/user/.vmodules
VTMP: OK, value: /tmp/v_1002

Git version: git version 2.41.0
Git vroot status: weekly.2023.45.1-54-ge9258c2a
.git/config present: true

CC version: cc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4)
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

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.

@lv37 lv37 added the Bug This tag is applied to issues which reports bugs. label Nov 16, 2023
@lv37 lv37 changed the title C error when initializing generic fixed size array C error when assigning generic fixed size array to a variable Nov 16, 2023
@shove70
Copy link
Contributor

shove70 commented Nov 17, 2023

No reproduction.

@lv37
Copy link
Contributor Author

lv37 commented Nov 17, 2023

No reproduction.

Are you compiling with tcc? Because compiling with clang makes it work

@shove70
Copy link
Contributor

shove70 commented Nov 17, 2023

v -cc clang, no reproduction.
tcc no reproduction too

@lv37
Copy link
Contributor Author

lv37 commented Nov 17, 2023

Are you using latest V?

@shove70
Copy link
Contributor

shove70 commented Nov 17, 2023

yes

@shove70
Copy link
Contributor

shove70 commented Nov 17, 2023

image

@lv37
Copy link
Contributor Author

lv37 commented Nov 17, 2023

Why does your v version say ab4330c?
when I do v up it says the latest version is 373da77

@shove70
Copy link
Contributor

shove70 commented Nov 17, 2023

oh sorry, it's 373da77.

I took a screenshot in my other branch by mistake.

@felipensp felipensp self-assigned this Nov 17, 2023
@felipensp felipensp added the Unit: cgen Bugs/feature requests, that are related to the default C generating backend. label Nov 17, 2023
@spytheman
Copy link
Member

image

I guess, the problem with the reproduction, may be that on macos, when it fails with tcc, it will retry with clang. A possible fix for making it reproduce is to try: v -cc tcc -no-retry-compilation a.v .

@shove70
Copy link
Contributor

shove70 commented Nov 19, 2023

I guess, the problem with the reproduction, may be that on macos, when it fails with tcc, it will retry with clang. A possible fix for making it reproduce is to try: v -cc tcc -no-retry-compilation a.v .

Thanks a lot. Yes, that's true

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. 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.

4 participants