Browse Source

Parse isa_string as C-style string

On C++11 and later, std::string is guaranteed to be null-terminated.
However, `*(str.end())` is NOT guaranteed to be '\0'.

So, we parse ISA string using C-style string buffer (raw pointers).
pull/871/head
Tsukasa OI 5 years ago
parent
commit
a00445c8e0
  1. 5
      riscv/processor.cc

5
riscv/processor.cc

@ -221,7 +221,8 @@ void processor_t::parse_isa_string(const char* str)
if (isa_string[4] != 'i')
bad_isa_string(str, "'I' extension is required");
auto p = isa_string.begin();
const char* isa_str = isa_string.c_str();
auto p = isa_str;
for (p += 4; islower(*p) && !strchr("zsx", *p); ++p) {
while (*all_subsets && (*p != *all_subsets))
++all_subsets;
@ -333,7 +334,7 @@ void processor_t::parse_isa_string(const char* str)
p = end;
}
if (*p) {
bad_isa_string(str, ("can't parse: " + std::string(p, isa_string.end())).c_str());
bad_isa_string(str, ("can't parse: " + std::string(p)).c_str());
}
}

Loading…
Cancel
Save