Skip to content

Commit

Permalink
Fix runtime error (left shift of negative value)
Browse files Browse the repository at this point in the history
Runtime error:

    src/training/util.h:37:28: runtime error: left shift of negative value -17

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Mar 12, 2019
1 parent 59cd716 commit 896698a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/training/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* File: util.h
* Description: Misc STL string utility functions.
* Author: Samuel Charron
* Created: Mon Nov 18 2013
*
* (C) Copyright 2013, Google Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -32,8 +31,8 @@
struct StringHash {
size_t operator()(const std::string& s) const {
size_t hash_code = 0;
const char* str = s.c_str();
for (int ch = 0; str[ch] != 0; ++ch) {
const uint8_t* str = reinterpret_cast<const uint8_t*>(s.c_str());
for (unsigned ch = 0; str[ch] != 0; ++ch) {
hash_code += str[ch] << (ch % 24);
}
return hash_code;
Expand All @@ -43,8 +42,8 @@ struct StringHash {
struct StringHash : public stdext::hash_compare <std::string> {
size_t operator()(const std::string& s) const {
size_t hash_code = 0;
const char* str = s.c_str();
for (int ch = 0; str[ch] != 0; ++ch) {
const uint8_t* str = reinterpret_cast<const uint8_t*>(s.c_str());
for (unsigned ch = 0; str[ch] != 0; ++ch) {
hash_code += str[ch] << (ch % 24);
}
return hash_code;
Expand Down

0 comments on commit 896698a

Please sign in to comment.