Skip to content

C error when attaching debugger to contexts containing heap variables #23979

@XiaoPangxie732

Description

@XiaoPangxie732

Describe the bug

Using $dbg in functions with heap variables would cause C error

Reproduction Steps

@[heap]
struct AStruct {
    a int
}

fn main() {
    st := AStruct{1}
    $dbg
}

Expected Behavior

Compiles & Runs fine

Current Behavior

================== C compilation error (from tcc): ==============
cc: C:/Users/***/AppData/Local/Temp/v_0/test.01JPQRBG3S0406NJY5H56824HW.tmp.c:5591: warning: implicit declaration of function 'tcc_backtrace'
cc: C:/Users/***/AppData/Local/Temp/v_0/test.01JPQRBG3S0406NJY5H56824HW.tmp.c:9712: error: cannot convert 'struct main__AStruct *' to 'struct main__AStruct'
...
cc: C:/Users/***/AppData/Local/Temp/v_0/test.01JPQRBG3S0406NJY5H56824HW.tmp.c:9712: error: cannot convert 'struct main__AStruct *' to 'struct main__AStruct'
(note: the original output was 3 lines long; it was truncated to its first 2 lines + the last line)
=================================================================
(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 .

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.9 87b1de8

Environment details (OS name and version, etc.)

V full version V 0.4.9 725e259.87b1de8
OS windows, Microsoft Windows 11 Pro 26100 64-bit
Processor 12 cpus, 64bit, little endian, Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
Memory 3.27GB/15.86GB
V executable ***
V last modified time 2025-03-19 17:50:00
V home dir OK, value: ***
VMODULES OK, value: ***
VTMP OK, value: ***
Current working dir OK, value: ***
Git version git version 2.38.1.windows.1
V git status weekly.2025.12-6-g87b1de82
.git/config present true
cc version N/A
gcc version N/A
clang version N/A
msvc version N/A
tcc version tcc version 0.9.27 (x86_64 Windows)
tcc git status thirdparty-windows-amd64 b425ac82
emcc version N/A
glibc version N/A

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.

Metadata

Metadata

Assignees

Labels

BugThis tag is applied to issues which reports bugs.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions