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 compilation error - cannot take the address of an rvalue of type 'u8' #22635

Closed
dbirjukov opened this issue Oct 23, 2024 · 0 comments · Fixed by #22637
Closed

C compilation error - cannot take the address of an rvalue of type 'u8' #22635

dbirjukov opened this issue Oct 23, 2024 · 0 comments · Fixed by #22637
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. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.

Comments

@dbirjukov
Copy link

dbirjukov commented Oct 23, 2024

V doctor:

V full version: V 0.4.8 97c6cd0
OS: macos, macOS, 12.7.6, 21H1320
Processor: 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz

getwd: /Users/dmitri/Dev/v_projects
vexe: /Users/dmitri/langs/v/v
vexe mtime: 2024-10-23 19:39:48

vroot: OK, value: /Users/dmitri/langs/v
VMODULES: OK, value: /Users/dmitri/.vmodules
VTMP: OK, value: /tmp/v_501

Git version: git version 2.37.1 (Apple Git-137.1)
Git vroot status: weekly.2024.22-767-g97c6cd09
.git/config present: true

CC version: Apple clang version 14.0.0 (clang-1400.0.29.202)
thirdparty/tcc status: thirdparty-macos-amd64 975f1ad8

What did you do?
./v -g -o vdbg cmd/v && ./vdbg bug.v

fn main() {
	a := 'abcd'
	b := a[0].str
	println(typeof(b).name)
}

What did you expect to see?

type name of the 'b' variable

What did you see instead?

================== C compilation error (from cc): ==============
cc: /tmp/v_501/bug.01JAXEEYN87HG0A44RZBZPYSJM.tmp.c:13637:83: error: cannot take the address of an rvalue of type 'u8' (aka 'unsigned char')
cc:         string (*b) (void) = __closure_create(_V_closure_u8_str_36, memdup_uncollectable(&string_at(a, 0), sizeof(u8)));
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 .

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-21084

@felipensp felipensp added Bug This tag is applied to issues which reports bugs. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. 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 Oct 23, 2024
@felipensp felipensp self-assigned this Oct 23, 2024
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. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants