Skip to content

Translate only the taken branch of constant if conditions - #488

Merged
nunoplopes merged 2 commits into
Cpp2Rust:masterfrom
lucic71:10-constant-if-branches
Oct 8, 2026
Merged

nunoplopes merged 2 commits into
Cpp2Rust:masterfrom
lucic71:10-constant-if-branches

Conversation

@lucic71

@lucic71 lucic71 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
template <typename T> unsigned long long widen(T v) {
  if (sizeof(T) > 4) {
    T hi = v;
    hi <<= 32;
    return hi;
  }
  return v;
}

The code inside if is not compilable. hi <<= 32 is a compilation error in rust when T = int.

@nunoplopes
nunoplopes merged commit 1f2982c into Cpp2Rust:master Oct 8, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants