Skip to content

V compilation bug #24326

Description

@jihaohaaaa
V version: V 0.4.10, press to see full `v doctor` output
V full version V 0.4.10 9b1937a.
OS macos, macOS, 15.4.1, 24E263
Processor 12 cpus, 64bit, little endian, Apple M2 Pro
Memory 0.54GB/16GB
V executable /opt/homebrew/Cellar/vlang/0.4.10/libexec/v
V last modified time 2025-03-20 11:42:00
V home dir OK, value: /opt/homebrew/Cellar/vlang/0.4.10/libexec
VMODULES OK, value: /Users/xachey/.vmodules
VTMP OK, value: /tmp/v_501
Current working dir OK, value: /Users/xachey/Desktop/vlang
Git version git version 2.49.0
V git status 4.4.32-67-g0e7f19f2 (64604 commit(s) behind V master)
.git/config present false
cc version Apple clang version 17.0.0 (clang-1700.0.13.3)
gcc version Apple clang version 17.0.0 (clang-1700.0.13.3)
clang version Homebrew clang version 20.1.3
tcc version N/A
tcc git status N/A
emcc version N/A
glibc version N/A

What did you do?
./v -g -o vdbg cmd/v && ./vdbg main.v && /Users/xachey/Desktop/vlang/main

import math { sqrt }
import time

fn get_hypot(a f64, b f64) f64 { //       ordinary function returning a value
    time.sleep(100 * time.millisecond)
    c := sqrt(a * a + b * b)
    return c
}

fn main() {
  start := time.now()
  mut arr := &[]thread f64{}
  for num in 1..1000{
    g := go get_hypot(num,num)
    arr << g
  }
  result := arr.wait()
  end := time.now()
  println("time duration: ${end-start}")
  println(result[1..10])
}

What did you see?

================== C compilation error (from cc): ==============
cc: /tmp/v_501/main.01JSS1RDRG92H9M60ZTQ9ZNWSG.tmp.c:7561:47: error: passing 'Array___v_thread_f64 *' (aka 'struct array *') to parameter of incompatible type 'Array___v_thread_f64' (aka 'struct array'); dereference with *
cc:  7561 |         Array_f64 result = Array___v_thread_f64_wait(arr);
cc:       |                                                      ^~~
cc:       |                                                      *
cc: /tmp/v_501/main.01JSS1RDRG92H9M60ZTQ9ZNWSG.tmp.c:2244:58: note: passing argument to parameter 'a' here
cc:  2244 | Array_f64 Array___v_thread_f64_wait(Array___v_thread_f64 a) {
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 .

What did you expect to see?

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.Unit: cgenBugs/feature requests, that are related to the default C generating backend.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions