Skip to content

CGen error #25941

@quaesitor-scientiam

Description

@quaesitor-scientiam
V version: V 0.4.12 68629be, press to see full `v doctor` output
V full version V 0.4.12 caf7d41.68629be
OS windows, Microsoft Windows 11 Pro 26200 64-bit
Processor 24 cpus, 64bit, little endian, AMD Ryzen 9 5900X 12-Core Processor
Memory 105.73GB/127.92GB
V executable S:\repo\vlang\v.exe
V last modified time 2025-12-10 14:15:04
V home dir OK, value: S:\repo\vlang
VMODULES OK, value: C:\Users\john3.vmodules
VTMP OK, value: S:\temp\v_0
Current working dir OK, value: S:\vProjects\AdventOfCode\Day1
env VFLAGS "-cc gcc -g"
Git version git version 2.52.0.windows.1
V git status weekly.2025.50-69-g68629bec
.git/config present true
cc version cc (x86_64-posix-seh-rev2, Built by MinGW-Builds project) 14.2.0
gcc version gcc (x86_64-posix-seh-rev2, Built by MinGW-Builds project) 14.2.0
clang version clang version 19.1.5
msvc version Microsoft (R) C/C++ Optimizing Compiler Version 19.44.35221 for x64
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

What did you do?
./v -g -o vdbg cmd/v && ./vdbg main.v && S:\vProjects\AdventOfCode\Day1\main.exe

module main

import os
import io

fn main() {
	mut file := os.open_file('data.txt','r')!
	defer { file.close() }
	cfg := io.BufferedReaderConfig{reader: file}
	mut reader := io.new_buffered_reader(cfg)
	start_pos := 50
	mut cur_pos := start_pos
	mut passcode_ctr := 0
	for {
		mut last_pos := cur_pos
		line := reader.read_line() or { break }
		dir := line[0].ascii_str()
		move := line[1..].int()
		if line == 'L174' {
			$dbg;
		}
		if dir == 'L' {
			cur_pos -= move
			if cur_pos < 0 {
				cur_pos = 100 + cur_pos
			}
			println('  ${last_pos} - ${move} = ${cur_pos}')
		}
		if dir == 'R' {
			cur_pos += move
			if cur_pos > 99 {
				cur_pos = cur_pos - 100
			}
			println('  ${last_pos} + ${move} = ${cur_pos}')
		}

		if cur_pos == 0 {
			passcode_ctr++
			println('*** ${line} ${cur_pos}')
		}
	}
	println('${passcode_ctr}')
}

What did you see?

S:\vProjects\AdventOfCode\Day1\main.v: In function 'main__main':
S:\vProjects\AdventOfCode\Day1\main.v:23:307: error: incompatible type for argument 1 of 'os__File_str'
   23 |                         cur_pos -= move
      |                                                                                                                                                                                                                                                                                                                   ^   
      |                                                                                                                                                                                                                                                                                                                   |
      |                                                                                                                                                                                                                                                                                                                   os__File *
S:\temp\v_0\main.01KC81HX54M37SAGR3FZASQWHX.tmp.c:2587:37: note: expected 'os__File' but argument is of type 'os__File *'
 2587 | static string os__File_str(os__File it) { return indent_os__File_str(it, 0);}
      |                            ~~~~~~~~~^~
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?

clean compile

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

No one assigned

    Labels

    Unit: cgenBugs/feature requests, that are related to the default C generating backend.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions