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

C error with shared struct that embeds another struct #23378

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

C error with shared struct that embeds another struct #23378

islonely opened this issue Jan 5, 2025 · 0 comments · May be fixed by #23394
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@islonely
Copy link
Contributor

islonely commented Jan 5, 2025

V doctor:

|V full version      |V 0.4.9 4225a34.495adc9
|:-------------------|:-------------------
|OS                  |macos, macOS, 15.1.1, 24B91
|Processor           |8 cpus, 64bit, little endian, Apple M3
|Memory              |0.71GB/16GB
|                    |
|V executable        |/Users/adamoates/v/v
|V last modified time|2025-01-04 20:09:49
|                    |
|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-29-g495adc9c
|.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 Foo {
mut:
	foo string
}

struct Bar {
	Foo
}

fn main() {
	shared bar := Bar{}
	rlock bar {
		println(bar.foo)
	}
}

What did you see?

================== C compilation error (from cc): ==============
cc:       |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc: /tmp/v_501/test.01JGT9FTGWQJWFRHETW6DYQQCT.tmp.c:9371:16: error: no member named 'Foo' in 'struct __shared__main__Bar'
cc:  9371 |                 println(bar->Foo.val.foo);
cc:       |                         ~~~  ^
cc: 1 warning and 1 error generated.
... (the original output was 9 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 print the value of bar.foo.

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.

Huly®: V_0.6-21809

@felipensp felipensp self-assigned this Jan 6, 2025
@felipensp felipensp added Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. 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. Status: Confirmed This bug has been confirmed to be valid by a contributor. 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