Skip to content

emit-c: == / != on two &str views compares addresses; LLVM compares contents #1560

Closed

Description

@ehartford

Found while checking D61 (#1480) backend parity; present on main ae609cd (the baseline compiler emits the same C).

fn eq(a: &str, b: &str) -> bool: a == b
fn main:
    let x = "ab"
    let y = "a" ++ "b"
    print(f"{eq(x, y)} {x == y}")

LLVM: true true. emit-c: false true. The view comparison in C compares the pointers (the #1137 class, fixed for < on the LLVM side). A test helper fn check(got: &str, want: &str) therefore diverges between backends; D61 parity runs used owned str parameters to get around it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions