vlang / v

Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automatic C => V translation. https://vlang.io
MIT License
35.71k stars 2.16k forks source link

(bug report summary) compiler error builder error #16674

Open BMJHayward opened 1 year ago

BMJHayward commented 1 year ago

Describe the bug

v -keepc -cg -showcc . on github.com/bmjhayward/vml with v -version V 0.3.2 70bb989 gives the following:

> C compiler cmd: '/home/brendan/code/v/thirdparty/tcc/tcc.exe' '@/tmp/v_1000/vml.tmp.c.rsp'
> C compiler response file "/tmp/v_1000/vml.tmp.c.rsp":
  -std=gnu99 -D_DEFAULT_SOURCE -g -o "/home/brendan/code/vml/vml" -D GC_BUILTIN_ATOMIC=1 -D GC_THREADS=1 -I "/home/brendan/code/v/thirdparty/libgc/include" "/tmp/v_1000/vml.tmp.c" -bt25 -rdynamic "/home/brendan/code/v/thirdparty/tcc/lib/libgc.a" -ldl -lpthread -lm 
> C compiler cmd: 'cc' '@/tmp/v_1000/vml.tmp.c.rsp'
> C compiler response file "/tmp/v_1000/vml.tmp.c.rsp":
  -std=gnu99 -D_DEFAULT_SOURCE -g -o "/home/brendan/code/vml/vml" -D GC_BUILTIN_ATOMIC=1 -D GC_THREADS=1 -I "/home/brendan/code/v/thirdparty/libgc/include" "/tmp/v_1000/vml.tmp.c" -rdynamic "/home/brendan/code/v/thirdparty/tcc/lib/libgc.a" -ldl -lpthread -lm 
/tmp/v_1000/vml.tmp.c:19197: error: '{' expected (got ";")
builder error: 
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

vml.tmp.c.tar.gz

Attached vml.tmp.c for reference.

Expected Behavior

I expected a clean compile, as with previous versions.

Current Behavior

C compiler cmd: '/home/brendan/code/v/thirdparty/tcc/tcc.exe' '@/tmp/v_1000/vml.tmp.c.rsp' C compiler response file "/tmp/v_1000/vml.tmp.c.rsp": -std=gnu99 -D_DEFAULT_SOURCE -g -o "/home/brendan/code/vml/vml" -D GC_BUILTIN_ATOMIC=1 -D GC_THREADS=1 -I "/home/brendan/code/v/thirdparty/libgc/include" "/tmp/v_1000/vml.tmp.c" -bt25 -rdynamic "/home/brendan/code/v/thirdparty/tcc/lib/libgc.a" -ldl -lpthread -lm C compiler cmd: 'cc' '@/tmp/v_1000/vml.tmp.c.rsp' C compiler response file "/tmp/v_1000/vml.tmp.c.rsp": -std=gnu99 -D_DEFAULT_SOURCE -g -o "/home/brendan/code/vml/vml" -D GC_BUILTIN_ATOMIC=1 -D GC_THREADS=1 -I "/home/brendan/code/v/thirdparty/libgc/include" "/tmp/v_1000/vml.tmp.c" -rdynamic "/home/brendan/code/v/thirdparty/tcc/lib/libgc.a" -ldl -lpthread -lm /tmp/v_1000/vml.tmp.c:19197: error: '{' expected (got ";") builder error:

C error. This should never happen.

Reproduction Steps

Run v -keepc -cg -showcc . on github.com/bmjhayward/vml with v -version V 0.3.2 70bb989 gives the following:

Possible Solution

Possible indexation error in the KMeans code in kmean.v

Additional Information/Context

No response

V version

V 0.3.2 70bb989

Environment details (OS name and version, etc.)

OS: linux, Linux Mint 20.1
Processor: 24 cpus, 64bit, little endian, AMD Ryzen 9 3900X 12-Core Processor
CC version: cc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

getwd: /home/brendan/code/vml
vmodules: /home/brendan/.vmodules
vroot: /home/brendan/code/v
vexe: /home/brendan/code/v/v
vexe mtime: 2022-12-14 10:45:03
is vroot writable: true
is vmodules writable: true
V full version: V 0.3.2 acbd93b.70bb989

Git version: git version 2.38.0
Git vroot status: weekly.2022.50-5-g70bb9895
.git/config present: true
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3
felipensp commented 1 year ago

Can you try again using a fresh V version?

BMJHayward commented 1 year ago

`v -version

V 0.3.2 46f1b20`

v -keepc -cg -showcc .
/home/brendan/code/v/vlib/rand/rand.v:345:30: error: unexpected token `[`, expecting `(`
  343 | // shuffle all elements until the end.
  344 | [direct_array_access]
  345 | pub fn (mut rng PRNG) shuffle[T](mut a []T, config config.ShuffleConfigStruct) ! {
      |                              ^
  346 |     config.validate_for(a)!
  347 |     new_end := if config.end == 0 { a.len } else { config.end }

and v up gives:

cannot compile `/home/brendan/code/v/cmd/tools/vup.v`: 
/home/brendan/code/v/vlib/os/file.c.v:591:32: error: unexpected token `[`, expecting `(`
  589 | 
  590 | // read_struct reads a single struct of type `T`
  591 | pub fn (mut f File) read_struct[T](mut t T) ! {
      |                                ^
  592 |     if !f.is_opened {
  593 |         return error_file_not_opened()

Still a bit stuck

JalonSolov commented 1 year ago

Is this still an issue with current V?