V: Bitwise operations on array elements broken

Created on 4 Jul 2019  ·  6Comments  ·  Source: vlang/v

V version:
Latest snapshot (d117c0a7429223441b5bb184a183ea14b090cf79)

OS:
Android/Termux

What did you do?
Tried to compile a program. Minimal example is:

fn test_bitwise() {
    mut var := [0; 1]
    mask := 1
    var[0] |= mask
    assert var[0] == 1
}

What did you expect to see?
A successfull compilation

What did you see instead?
````
WARNING: linker: ./v: .vlang//bitwise_test.c:3110:14: error: expected expression
int tmp4 = |= mask;
^
1 error generated.
V panic: clang error

Bug

All 6 comments

Update: I get the same error even with plain variables, not just array elements. Apparently, all bitwise operations are broken.

Update 2: Further research showed that all assignment operations beyond simple "=" are broken. "+=", "|=" etc. will not compile. Of course, this error can still be circumvented by using "var = var | value".

@pzb568 The problem is not in Termux. I can build V. I can not use "|=", "^=", "+=" etc in my programs, regardless of architecture.

@ciubotaru This seems to be working at the moment, at least in Linux.

Indeed, it was fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arg2das picture arg2das  ·  3Comments

taojy123 picture taojy123  ·  3Comments

penguindark picture penguindark  ·  3Comments

vtereshkov picture vtereshkov  ·  3Comments

lobotony picture lobotony  ·  3Comments