Skip to content

cgen: array assertion fails on MacBook Pro M2 #24529

Description

@gchumillas

Describe the bug

The following code does not terminate properly on an MacBook Pro M2 (and M1 too):

// main_test.v
fn foo(i int) !int {
    m := [3, 4, 5]

    // This works
    // r := m[i] or {
    //     return error('bad boy!')
    // }

    // this does not work
    r := m[i]!

    return r
}

fn test_foo() {
    g := foo(3) or { 12 }
    assert g == 12
}

Test the file:

v test main_test.v

See the output:

fn test_foo
   > assert g == 12
     Left value (len: 7): `5119952` (this is a random value)
    Right value (len: 2): `12`

Reproduction Steps

Buy a Macbook Pro or ask a friend who already has one for a favor and run the code above.

Expected Behavior

It should complain.

Current Behavior

It doesn't complain.

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.10 6be298d

Environment details (OS name and version, etc.)

V full version V 0.4.10 6be298d
OS macos, macOS, 15.5, 24F74
Processor 10 cpus, 64bit, little endian, Apple M4
Memory 0.14GB/16GB
V executable /Users/gonzalo/Documents/Projects/Personal/v/v
V last modified time 2025-05-20 11:21:19
V home dir OK, value: /Users/gonzalo/Documents/Projects/Personal/v
VMODULES OK, value: /Users/gonzalo/.vmodules
VTMP OK, value: /tmp/v_501
Current working dir OK, value: /Users/gonzalo/Documents/Projects/Personal/v
Git version git version 2.49.0
V git status 6be298d
.git/config present true
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 Apple clang version 17.0.0 (clang-1700.0.13.3)
tcc version tcc version 0.9.28rc 2024-02-05 HEAD@105d70f7 (AArch64 Darwin)
tcc git status thirdparty-macos-arm64 e447816c
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.Unit: cgenBugs/feature requests, that are related to the default C generating backend.

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions