Skip to content

Error when shortening ipv6 adresses with long zero runs. #22440

@bondehagen

Description

@bondehagen

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

Running the following:

const std = @import("std");

pub fn main() !void {
    const addr = try std.net.Address.parseIp6("2001:db8:0000:0000:0001:0000:0000:0002", 0);
    const addr2 = try std.net.Address.parseIp6("2001:db8:0000:0000:0000:0000:0001:0002", 0);
    std.debug.print("Parsed address: \n{}\n", .{addr});
    std.debug.print("{}", .{addr2});
}

Gives the following output:

Parsed address: 
[2001:db8::1:2]:0
[2001:db8::1:2]:0

Expected Behavior

This is the correct compressed form:

Parsed address: 
[2001:db8::1:0:0:2]:0
[2001:db8::1:2]:0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions