Skip to content

C error on pointer.free() #23592

Description

@islonely
V version: V 0.4.9 3343fb7, press to see full `v doctor` output
V full version V 0.4.9 4225a34.3343fb7
OS macos, macOS, 15.2, 24C101
Processor 8 cpus, 64bit, little endian, Apple M3
Memory 0.5GB/16GB
V executable /Users/adamoates/v/v
V last modified time 2025-01-26 20:49:38
V home dir OK, value: /Users/adamoates/v
VMODULES OK, value: /Users/adamoates/.vmodules
VTMP OK, value: /tmp/v_501
Current working dir OK, value: /Users/adamoates/repos/bibleclock
Git version git version 2.39.5 (Apple Git-154)
V git status weekly.2025.03-44-g3343fb79
.git/config present true
cc version Apple clang version 16.0.0 (clang-1600.0.26.6)
gcc version Apple clang version 16.0.0 (clang-1600.0.26.6)
clang version Apple clang version 16.0.0 (clang-1600.0.26.6)
tcc version tcc version 0.9.28rc 2024-02-05 HEAD@105d70f7 (AArch64 Darwin)
tcc git status thirdparty-macos-arm64 713692d4
emcc version N/A
glibc version N/A

What did you do?
./v -g -o vdbg cmd/v && ./vdbg /Users/adamoates/Documents/test.v && /Users/adamoates/Documents/test

fn main() {
	unsafe {
		data := malloc(2)
		data.free()
	}
}

What did you see?

u8
could not generate free method 'u8_free' for type 'u8'
================== C compilation error (from cc): ==============
cc: /tmp/v_501/test.01JJJ61JWSFYXDF5RZQGB5S9DR.tmp.c:5554:3: error: call to undeclared function 'u8_free'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
cc:  5554 |                 u8_free(data);
cc:       |                 ^
cc: 1 error generated.
================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
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 .

What did you expect to see?

Expected V error to tell me to use builtin free(data) instead of data.free().

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.

Metadata

Metadata

Assignees

Labels

BugThis tag is applied to issues which reports bugs.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.Unit: cgenBugs/feature requests, that are related to the default C generating backend.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions