Skip to content

Commit

Permalink
Explicit template parameters
Browse files Browse the repository at this point in the history
Summary:
uniform_int_distribution has undefined behavior (UB) if data type is not one of short, int, long, long long, unsigned short, unsigned int, unsigned long, or unsigned long long.

MSVC is strict about UB and doesn't allow uint8_t.

MSVC also can't deduce one of the template parameter. Adding it explicitly.

Reviewed By: protonu

Differential Revision: D18940804

fbshipit-source-id: 839f97d6437a4f7011b2334f85d8e1a4dd329ec8
  • Loading branch information
dskhudia authored and jspark1105 committed Mar 21, 2020
1 parent 4029550 commit 535d400
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bench/BenchUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ std::default_random_engine eng;

template <typename T>
void randFill(aligned_vector<T>& vec, T low, T high, std::true_type) {
std::uniform_int_distribution<T> dis(low, high);
std::uniform_int_distribution<int> dis(low, high);
std::generate(vec.begin(), vec.end(), [&] { return dis(eng); });
}

Expand Down
3 changes: 2 additions & 1 deletion test/I64Test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ TEST_F(Int64GemmTest, test) {
C_ref.data(),
n);

compare_validate_buffers(C_ref.data(), C.data(), m, n, n, 0L);
compare_validate_buffers<int64_t>(
C_ref.data(), C.data(), m, n, n, 0L);
}
} // transb
} // transa
Expand Down

0 comments on commit 535d400

Please sign in to comment.