From 0458303ed5a931b1e3b0e24c0d26fa961ad3c0dc Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 21 Nov 2025 13:11:29 +0200 Subject: [PATCH] markused: fix missing builtin__memdup definition, when an option struct field is used (fix #25801) (#25802) --- ..._program_with_struct_option_fields.c.must_have | 1 + ...p_used_by_program_with_struct_option_fields.vv | 15 +++++++++++++++ vlib/v/markused/walker.v | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 vlib/v/gen/c/testdata/memdup_used_by_program_with_struct_option_fields.c.must_have create mode 100644 vlib/v/gen/c/testdata/memdup_used_by_program_with_struct_option_fields.vv diff --git a/vlib/v/gen/c/testdata/memdup_used_by_program_with_struct_option_fields.c.must_have b/vlib/v/gen/c/testdata/memdup_used_by_program_with_struct_option_fields.c.must_have new file mode 100644 index 000000000..f810a82b6 --- /dev/null +++ b/vlib/v/gen/c/testdata/memdup_used_by_program_with_struct_option_fields.c.must_have @@ -0,0 +1 @@ +voidptr builtin__memdup(voidptr src, isize sz); diff --git a/vlib/v/gen/c/testdata/memdup_used_by_program_with_struct_option_fields.vv b/vlib/v/gen/c/testdata/memdup_used_by_program_with_struct_option_fields.vv new file mode 100644 index 000000000..9224fd3d9 --- /dev/null +++ b/vlib/v/gen/c/testdata/memdup_used_by_program_with_struct_option_fields.vv @@ -0,0 +1,15 @@ +struct Foo { + data &int +} + +struct FooHolder { + foo ?Foo +} + +struct Program { + foo ?Foo +} + +fn main() { + _ := Program{} +} diff --git a/vlib/v/markused/walker.v b/vlib/v/markused/walker.v index b9d6564cc..0addbbd83 100644 --- a/vlib/v/markused/walker.v +++ b/vlib/v/markused/walker.v @@ -1428,7 +1428,7 @@ fn (mut w Walker) mark_resource_dependencies() { w.fn_by_name('malloc') w.fn_by_name('tos3') } - if w.uses_memdup { + if w.uses_memdup || w.used_none > 0 { w.fn_by_name('memdup') } if w.uses_debugger { -- 2.39.5