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: using a mut method of mut generic array parameter makes undefined symbol error #23566

Closed
lemoncmd opened this issue Jan 24, 2025 · 1 comment · Fixed by #23568
Closed
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

@lemoncmd
Copy link
Contributor

lemoncmd commented Jan 24, 2025

Describe the bug

An array of generic type for parameters are frequently used in many cases.
However, directly writing any mutable methods of the mutable parameters makes undefined symbol error.

Reproduction Steps

fn grow[T](mut arr []T) {
        arr.grow_cap(10)
}

mut arr := []int{}
grow(mut arr)

Expected Behavior

compile, and it should use array_grow_cap.

Current Behavior

Array_int_grow_cap is used, and it makes an error below.

/tmp/v_1000/method.01JJC2RJJMY6ZM27DYT2YEVTJ3.tmp.c:5738: warning: implicit declaration of function 'Array_int_grow_cap'
/home/lemon/git/v/thirdparty/tcc/lib/libgc.a: error: 'GC_noop1_ptr' defined twice
tcc: error: undefined symbol 'Array_int_grow_cap'

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.9 da5bb68

Environment details (OS name and version, etc.)

V full version V 0.4.9 7eec8b1.da5bb68
OS linux, Linux version 6.1.21.2-microsoft-standard-WSL2+ (root@DESPTOP-LEMON) (gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #2 SMP PREEMPT_DYNAMIC Fri Jul 21 23:54:26 JST 2023 (WSL 2)
Processor 16 cpus, 64bit, little endian, 11th Gen Intel(R) Core(TM) i7-11700KF @ 3.60GHz
Memory 30.05GB/31.3GB
V executable /home/lemon/git/v/v
V last modified time 2025-01-24 04:32:39
V home dir OK, value: /home/lemon/git/v
VMODULES OK, value: /home/lemon/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/lemon/vtest
Git version git version 2.48.1
V git status 0.3.5-3653-gda5bb68b-dirty (3 commit(s) behind V master)
.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.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.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.

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

Connected to Huly®: V_0.6-21994

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