Skip to content

Inconsistency between division operator vs assignment (debug only) #14816

@adriandelgado

Description

@adriandelgado

Zig Version

0.11.0-dev.1863+a63134a4a

Steps to Reproduce and Observed Behavior

Run this code on debug mode.

const print = @import("std").debug.print;

pub fn main() void {
    const original: u256 = 99999999999999999999000000000000000000000;
    const divisor: u256 = 10000000000000000000000000000000000000000;
    print("Division operation: {}  (correct)\n", .{original / divisor});

    var num = original;
    num /= divisor;

    print("Division asignment: {}\n", .{num});
}

It outputs:

Division operation: 9  (correct)
Division asignment: 10

Expected Behavior

I expected both operations to behave the same way just like in any release mode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions