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 when returning fixed size array from unsafe function #23546

Closed
Larsimusrex opened this issue Jan 21, 2025 · 1 comment · Fixed by #23548
Closed

cgen error when returning fixed size array from unsafe function #23546

Larsimusrex opened this issue Jan 21, 2025 · 1 comment · Fixed by #23548
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

@Larsimusrex
Copy link

Larsimusrex commented Jan 21, 2025

Describe the bug

A function call to an unsafe function returning a fixed size array produces a c compiler error, when wrapped with a unsafe block.

Reproduction Steps

The following code will not compile.

@[unsafe]
fn test() [5]int {
	return [5]int{}
}

fn main() {
	foo := unsafe { test() }

	println(foo)
}

Expected Behavior

Compiles with no errors.

Current Behavior

======== Output of the C Compiler (/home/lars/v/thirdparty/tcc/tcc.exe) ========
/tmp/v_1000/test.01JJ5CVRNZN5KWEVYH7S4GY15M.tmp.c:5896: error: '{' expected (got ";")
================================================================================
======== Output of the C Compiler (cc) ========
/tmp/v_1000/test.01JJ5CVRNZN5KWEVYH7S4GY15M.tmp.c: In function 'main__main':
/tmp/v_1000/test.01JJ5CVRNZN5KWEVYH7S4GY15M.tmp.c:5896:33: error: invalid initializer
 5896 |         Array_fixed_int_5 foo = main__test().ret_arr;
      |                                 ^~~~~~~~~~
===============================================

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.9 4e68a86

Environment details (OS name and version, etc.)

V full version V 0.4.9 d680c42.4e68a86
OS linux, "Void Linux"
Processor 12 cpus, 64bit, little endian, AMD Ryzen 5 5600G with Radeon Graphics
Memory 4.83GB/15.52GB
V executable /home/lars/v/v
V last modified time 2025-01-21 21:39:55
V home dir OK, value: /home/lars/v
VMODULES OK, value: /home/lars/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir contains spaces, value: /home/lars/Robotron z1013/Pixel Graphics v3/generator
Git version git version 2.48.1
V git status weekly.2024.36-1031-g4e68a860
.git/config present true
cc version cc (GCC) 13.2.0
gcc version gcc (GCC) 13.2.0
clang version clang version 17.0.6
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.39

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.

@Larsimusrex Larsimusrex added the Bug This tag is applied to issues which reports bugs. label Jan 21, 2025
Copy link

Connected to Huly®: V_0.6-21974

@felipensp felipensp self-assigned this Jan 21, 2025
@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. labels Jan 21, 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