aboutsummaryrefslogtreecommitdiff
path: root/riscv/processor.cc
diff options
context:
space:
mode:
authorTsukasa OI <research_trasio@irq.a4lg.com>2021-12-02 11:29:19 +0900
committerTsukasa OI <research_trasio@irq.a4lg.com>2021-12-02 11:29:19 +0900
commita00445c8e04db6c96dabccf23c04ab2e4571ca2b (patch)
treef9210708e1326b445af6fc24524dd60cb4f08f68 /riscv/processor.cc
parent375d55ef441e335660ccfc2d78fb93ceb804478a (diff)
downloadspike-a00445c8e04db6c96dabccf23c04ab2e4571ca2b.zip
spike-a00445c8e04db6c96dabccf23c04ab2e4571ca2b.tar.gz
spike-a00445c8e04db6c96dabccf23c04ab2e4571ca2b.tar.bz2
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).
Diffstat (limited to 'riscv/processor.cc')
-rw-r--r--riscv/processor.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/riscv/processor.cc b/riscv/processor.cc
index ed9042f..a7b4a5b 100644
--- a/riscv/processor.cc
+++ b/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());
}
}