Skip to content

get_trimmed_lines() results in C error #24187

@awildberg

Description

@awildberg
V version: V 0.4.10 d54a823
V full version V 0.4.10 f27181e.d54a823
OS macos, macOS, 15.4, 24E248
Processor 11 cpus, 64bit, little endian, Apple M3 Pro
Memory 2.71GB/36GB
V executable /usr/local/vlang/v
V last modified time 2025-04-11 12:04:15
V home dir NOT writable, value: /usr/local/vlang
VMODULES OK, value: /Users/user/.vmodules
VTMP OK, value: /tmp/v_501
Current working dir OK, value: /Users/user/Documents/testing
Git version git version 2.39.5 (Apple Git-154)
To add an exception for this directory, call:
git config --global --add safe.directory /usr/local/vlang

|.git/config present |true
| |
|cc version |Apple clang version 17.0.0 (clang-1700.0.13.3)
|gcc version |Apple clang version 17.0.0 (clang-1700.0.13.3)
|clang version |Apple clang version 17.0.0 (clang-1700.0.13.3)
|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 get.v && /Users/_/Documents/testing/get

import os

fn main() {
  s := os.get_trimmed_lines()
  println(s[0])
}

What did you see?

================== C compilation error (from cc): ==============
cc: /tmp/v_501/get.01JRJBTMG679EKCZ48R9B6315N.tmp.c:6405:47: error: call to undeclared function 'string_substr_ni'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
cc:  6405 |                 array_push((array*)&lines, _MOV((string[]){ string_substr_ni(line, 0, end) }));
cc:       |                                                             ^
cc: /tmp/v_501/get.01JRJBTMG679EKCZ48R9B6315N.tmp.c:6405:47: note: did you mean 'string_substr'?
cc: /tmp/v_501/get.01JRJBTMG679EKCZ48R9B6315N.tmp.c:5491:8: note: 'string_substr' declared here
cc:  5491 | string string_substr(string s, int start, int _end) {
cc:       |        ^
cc: /tmp/v_501/get.01JRJBTMG679EKCZ48R9B6315N.tmp.c:6405:47: error: incompatible integer to pointer conversion initializing 'u8 *' (aka 'unsigned char *') with an expression of type 'int' [-Wint-conversion]
cc:  6405 |                 array_push((array*)&lines, _MOV((string[]){ string_substr_ni(line, 0, end) }));
cc:       |                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc: 2 errors 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?

Compiled code

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.Unit: CompilerBugs/feature requests, that are related to the V compiler in general.Unit: cgenBugs/feature requests, that are related to the default C generating backend.Unit: markusedBugs/feature requests, that are related to the -skip-unused.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions