Skip to content

-autofree C compiler error #23527

@mike-ward

Description

@mike-ward

Describe the bug

Receiving a C error when trying to compile https://github.com/mike-ward/lsv with -autofree

Reproduction Steps

git clone https://github.com/mike-ward/lsv.git
cd lsv
v -prod -autofree lsv -o bin/lsv

Expected Behavior

Successful build.

Current Behavior

╰─ ▶ v -prod -autofree lsv -o bin/lsv
================== C compilation error (from cc): ==============
cc: /tmp/v_501/lsv.01JHZT617Q1HEWNACNB4SWYPF9.tmp.c:4554:53: error: passing 'string' (aka 'struct string') to parameter of incompatible type 'string *' (aka 'struct string *'); take the address with &
cc:  4554 |                 int result = main__string_compare(/*autofree arg*/_arg_expr_main_string_compare_1_1383, /*autofree arg*/_arg_expr_main_string_compare_2_1383, _V_closure_ctx->options.sort_ignore_case);
cc:       |                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc:       |                                                                   &
cc: /tmp/v_501/lsv.01JHZT617Q1HEWNACNB4SWYPF9.tmp.c:3520:50: note: passing argument to parameter 'a' here
cc:  3520 | VV_LOCAL_SYMBOL int main__string_compare(string* a, string* b, bool ignore_case);
cc:       |                                                  ^
cc: /tmp/v_501/lsv.01JHZT617Q1HEWNACNB4SWYPF9.tmp.c:15947:47: error: use of undeclared identifier '_arg_expr_main_real_length_1_3749'
cc:  15947 |                 int _t2 = main__real_length(/*autofree arg*/_arg_expr_main_real_length_1_3749);
cc:        |                                                             ^
cc: /tmp/v_501/lsv.01JHZT617Q1HEWNACNB4SWYPF9.tmp.c:16490:47: error: expected expression
cc:  16490 | string _arg_expr_main_right_pad_end_1_10067 = }
... (the original output was 86 lines long, and was truncated to 12 lines)
================================================================
(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 .

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.9 11c59cf

Environment details (OS name and version, etc.)

V full version V 0.4.9 da3112e.11c59cf
OS macos, macOS, 15.1.1, 24B91
Processor 8 cpus, 64bit, little endian, Apple M2
Memory 0.16GB/8GB
V executable /Users/mike/Documents/github/v/v
V last modified time 2025-01-19 16:20:10
V home dir OK, value: /Users/mike/Documents/github/v
VMODULES OK, value: /Users/mike/.vmodules
VTMP OK, value: /tmp/v_501
Current working dir OK, value: /Users/mike/Documents/github/lsv
Git version git version 2.48.0
V git status weekly.2025.1-88-g11c59cf8
.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

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

No one assigned

    Labels

    AutofreeBugs/feature requests, that are related to -autofree.BugThis tag is applied to issues which reports bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions