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 error when trying to thread.wait() on an unset thread field of struct #23390

Open
islonely opened this issue Jan 6, 2025 · 0 comments · May be fixed by #23392
Open

cgen error when trying to thread.wait() on an unset thread field of struct #23390

islonely opened this issue Jan 6, 2025 · 0 comments · May be fixed by #23392
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@islonely
Copy link
Contributor

islonely commented Jan 6, 2025

V version: V 0.4.9 738f847, press to see full `v doctor` output
V full version V 0.4.9 4225a34.738f847
OS macos, macOS, 15.1.1, 24B91
Processor 8 cpus, 64bit, little endian, Apple M3
Memory 0.48GB/16GB
V executable /Users/adamoates/v/v
V last modified time 2025-01-06 06:05:14
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/Documents/shattlebip
Git version git version 2.39.5 (Apple Git-154)
V git status weekly.2024.53-37-g738f847f
.git/config present true
cc version Apple clang version 16.0.0 (clang-1600.0.26.4)
gcc version Apple clang version 16.0.0 (clang-1600.0.26.4)
clang version Apple clang version 16.0.0 (clang-1600.0.26.4)
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

struct Client {
mut:
	network_thread thread
}

fn main() {
	mut client := &Client{}
	client.network_thread.wait()
}

What did you see?

================== C compilation error (from cc): ==============
cc:       |                                                                                         ^~~
cc: /tmp/v_501/test.01JGX3FVGN7KNACR63BX3H1ZC6.tmp.c:5562:2: error: call to undeclared function '__v_thread_wait'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
cc:  5562 |         __v_thread_wait(client->network_thread);
cc:       |         ^
cc: 1 warning and 1 error generated.
... (the original output was 7 lines long, and was truncated to 5 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 .

What did you expect to see?

Expected code to compile and when ran just skip right over client.network_thead.wait() since the thread has not been set. V would normally guard against this by not allowing you to set variables of uninitialized threads (i.e. no mut t := thread{}). It does not, however, check struct fields the same way.

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.

@felipensp felipensp linked a pull request Jan 6, 2025 that will close this issue
@felipensp felipensp self-assigned this Jan 6, 2025
@felipensp felipensp added Bug This tag is applied to issues which reports bugs. Unit: cgen Bugs/feature requests, that are related to the default C generating backend. labels Jan 6, 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. 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