Compiler bug when trying to return an interface-optional with a fallback default value #21660
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.
Describe the bug
The function in question tries to return a result of the interface directly from the struct, which itself is an optional. If the struct value is not set it invokes a function to create a default. The produced C code does not seem to realize that the value is no longer an optional.
Reproduction Steps
There is a full reproducer here:
https://github.com/dasidiot/v-option-bug
getwd: /home/user/src/v
vexe: /home/user/src/v/v
vexe mtime: 2024-06-09 19:42:11
vroot: OK, value: /home/user/src/v
VMODULES: OK, value: /home/user/.vmodules
VTMP: OK, value: /tmp/v_1000
Git version: git version 2.39.2
Git vroot status: weekly.2024.22-47-g1af7b7c3
.git/config present: true
CC version: cc (Debian 12.2.0-14) 12.2.0
thirdparty/tcc status: thirdparty-linux-amd64 40e5cbb5
The text was updated successfully, but these errors were encountered: