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

multi_struct redefinition when returning !(int, voidptr) result in an or block #17343

Closed
Uhrbaan opened this issue Feb 17, 2023 · 0 comments · Fixed by #21144
Closed

multi_struct redefinition when returning !(int, voidptr) result in an or block #17343

Uhrbaan opened this issue Feb 17, 2023 · 0 comments · Fixed by #21144
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

@Uhrbaan
Copy link

Uhrbaan commented Feb 17, 2023

Describe the bug

when returning two values (an int, u32 or any and a voidptr) in an or block, a second multi_return struct is created with the same values (in this case multi_return_int_voidptr) wich causes a redefinition error.

Expected Behavior

the multi_return struct should not be recreated

Current Behavior

tcc error:
error: struct/union/enum already defined

Reproduction Steps

fn ret_int_ptr(arg int) !(int, voidptr) {
	if arg < 0 {
		return error('argument is smaller then zero')
	}
	return 1, [1, 2, 3].data
}

mut val1 := 0
mut val2 := unsafe { nil }

val1, val2 = ret_int_ptr(0) or {
	println(err)
	val1, val2
}

Possible Solution

probably a compiler bug.

Additional Information/Context

in the example, changing val2 to an int type resolves the error, it just creates a warning because of the pointer to int conversion.

V version

V 0.3.3 e066d1d

Environment details (OS name and version, etc.)

OS: linux, "Manjaro Linux"
Processor: 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
CC version: cc (GCC) 12.2.0

getwd: /home/uhrbaan/Documents/code/vulkan/learn_vk
vmodules: /home/uhrbaan/.vmodules
vroot: /home/uhrbaan/vlang/v
vexe: /home/uhrbaan/vlang/v/v
vexe mtime: 2023-02-16 19:20:09
is vroot writable: true
is vmodules writable: true
V full version: V 0.3.3 ef5be22.e066d1d

Git version: git version 2.39.0
Git vroot status: weekly.2023.07-14-ge066d1d3-dirty
.git/config present: true
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

@Uhrbaan Uhrbaan added the Bug This tag is applied to issues which reports bugs. label Feb 17, 2023
@felipensp felipensp self-assigned this Mar 16, 2023
@felipensp felipensp added the Unit: cgen Bugs/feature requests, that are related to the default C generating backend. label Mar 16, 2023
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