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

v -translated compile fail with export #21739

Closed
kbkpbot opened this issue Jun 26, 2024 · 0 comments
Closed

v -translated compile fail with export #21739

kbkpbot opened this issue Jun 26, 2024 · 0 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@kbkpbot
Copy link
Contributor

kbkpbot commented Jun 26, 2024

Describe the bug

convert v from c, and the result code can't compile

Reproduction Steps

test.v

module main

@[export:'S_sfx']
const s_sfx   = [0,1,2]

fn main() {

	println(s_sfx[0])
}

compile test.v with -translated

 v test.v -translated

Expected Behavior

compile ok

Current Behavior

will fail with :

==================
/tmp/v_1000/test_sfx.01J1A7PTBSAB7Z78SXWDMMJXXD.tmp.c:12735: error: 's_sfx' undeclared
...
==================
(Use `v -cg` to print the entire error message)

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

the generated c code:

Array_int main__s_sfx; // inited later
main__s_sfx = new_array_from_c_array(3, 3, sizeof(int), _MOV((int[3]){0, 1, 2}));
...
VV_LOCAL_SYMBOL void main__main(void) {
        println(int_str((*(int*)array_get(s_sfx, 0))));
}

seems that has something wrong with the naming rule.

Additional Information/Context

BTW, I can't see S_sfx in the generated C code.

V version

V full version: V 0.4.6 96751ed.98a1ee2

Environment details (OS name and version, etc.)

V full version: V 0.4.6 96751ed.98a1ee2
OS: linux, Ubuntu 22.04.4 LTS
Processor: 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz

getwd: /home/mars/v/9
vexe: /media/HD/github/lang/v/v
vexe mtime: 2024-06-25 07:37:30

vroot: OK, value: /media/HD/github/lang/v
VMODULES: OK, value: /home/mars/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.34.1
Git vroot status: weekly.2024.26-5-g094c30c3
.git/config present: true

CC version: cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
thirdparty/tcc status: thirdparty-linux-amd64 40e5cbb5

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.

@kbkpbot kbkpbot added the Bug This tag is applied to issues which reports bugs. label Jun 26, 2024
@kbkpbot kbkpbot closed this as completed Jul 24, 2024
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.
Projects
None yet
Development

No branches or pull requests

1 participant