Skip to content

Commit

Permalink
Fix std::exeception catch-by-reference gcc9 compile error (#7380)
Browse files Browse the repository at this point in the history
Compile error (for gcc-9) created by change in #7254 as mentioned in the following comment.
#7254 (comment)

Core C++ Guidelines for catching exceptions says to always catch by reference.
Polymorphism is supported only with pointers and references.
http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Re-exception-ref

Authors:
  - David (@davidwendt)

Approvers:
  - Ram (Ramakrishna Prabhu) (@rgsl888prabhu)
  - MithunR (@mythrocks)

URL: #7380
  • Loading branch information
davidwendt authored Feb 13, 2021
1 parent 7c609d2 commit a7927e3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cpp/src/text/subword/load_hash_file.cu
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ uint32_t str_to_uint32(std::string const& str, uint64_t line_no)
{
try {
return std::stoi(str); // there is no std::stoui
} catch (std::exception exc) {
} catch (std::exception const& exc) {
std::string message("Line ");
message += std::to_string(line_no) + ": ";
message += "cannot convert integer from '";
message += str;
message += "': ";
message += exc.what();
std::cerr << message << std::endl;
throw exc;
throw;
}
}

Expand All @@ -147,15 +147,15 @@ uint64_t str_to_uint64(std::string const& str, uint64_t line_no)
{
try {
return std::stoul(str);
} catch (std::exception exc) {
} catch (std::exception const& exc) {
std::string message("Line ");
message += std::to_string(line_no) + ": ";
message += "cannot convert integer from '";
message += str;
message += "': ";
message += exc.what();
std::cerr << message << std::endl;
throw exc;
throw;
}
}
} // namespace
Expand Down

0 comments on commit a7927e3

Please sign in to comment.