Skip to content

Fix std::map::operator[] - #672

Merged
nunoplopes merged 5 commits into
Cpp2Rust:masterfrom
lucic71:map-subscript-default
Nov 20, 2026
Merged

nunoplopes merged 5 commits into
Cpp2Rust:masterfrom
lucic71:map-subscript-default

Conversation

@lucic71

@lucic71 lucic71 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Rules have a mechanism where they replace <T>::default() with the default declared by the STL type. For example, <T>::default() becomes vec![0] instead of <Vec<i8>>::default() for a std::string because:

fn t1() -> Vec<i8> {
    vec![0]
}

std::map::operator[] did not write <T>::defaut() inside the rule so the translation of std::map<T, std::string> is wrong: the value of the map is an empty string instead of a NUL terminated string.

@nunoplopes
nunoplopes merged commit 1e216f4 into Cpp2Rust:master Nov 20, 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