mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 03:17:15 +02:00
Merge pull request #78 from cmazakas/feature/test-suite-ub-fixes
Fix integer overflow UB in test suite
This commit is contained in:
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
@ -49,6 +49,7 @@ jobs:
|
|||||||
cxxstd: "03,11,14,17,2a"
|
cxxstd: "03,11,14,17,2a"
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
install: g++-11
|
install: g++-11
|
||||||
|
sanitizers: true
|
||||||
- toolset: clang
|
- toolset: clang
|
||||||
compiler: clang++-3.9
|
compiler: clang++-3.9
|
||||||
cxxstd: "03,11,14"
|
cxxstd: "03,11,14"
|
||||||
@ -96,9 +97,11 @@ jobs:
|
|||||||
compiler: clang++-12
|
compiler: clang++-12
|
||||||
cxxstd: "03,11,14,17,2a"
|
cxxstd: "03,11,14,17,2a"
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
|
sanitizers: true
|
||||||
- toolset: clang
|
- toolset: clang
|
||||||
cxxstd: "03,11,14,17"
|
cxxstd: "03,11,14,17"
|
||||||
os: macos-10.15
|
os: macos-10.15
|
||||||
|
sanitizers: true
|
||||||
|
|
||||||
runs-on: ${{matrix.os}}
|
runs-on: ${{matrix.os}}
|
||||||
|
|
||||||
@ -139,7 +142,11 @@ jobs:
|
|||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
cd ../boost-root
|
cd ../boost-root
|
||||||
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
|
./b2 -j3 libs/$LIBRARY/test \
|
||||||
|
toolset=${{matrix.toolset}} \
|
||||||
|
cxxstd=${{matrix.cxxstd}} \
|
||||||
|
variant=debug,release \
|
||||||
|
${{(matrix.sanitizers && 'address-sanitizer=norecover undefined-sanitizer=norecover') || ''}}
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
strategy:
|
strategy:
|
||||||
|
@ -194,18 +194,19 @@ namespace test {
|
|||||||
|
|
||||||
std::size_t hash_impl(object const& x) const
|
std::size_t hash_impl(object const& x) const
|
||||||
{
|
{
|
||||||
int result;
|
unsigned result;
|
||||||
switch (tag_) {
|
switch (tag_) {
|
||||||
case 1:
|
case 1:
|
||||||
result = x.tag1_;
|
result = static_cast<unsigned>(x.tag1_);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
result = x.tag2_;
|
result = static_cast<unsigned>(x.tag2_);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result = x.tag1_ + x.tag2_;
|
result =
|
||||||
|
static_cast<unsigned>(x.tag1_) + static_cast<unsigned>(x.tag2_);
|
||||||
}
|
}
|
||||||
return static_cast<std::size_t>(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator==(hash const& x1, hash const& x2)
|
friend bool operator==(hash const& x1, hash const& x2)
|
||||||
|
@ -195,34 +195,36 @@ namespace test {
|
|||||||
|
|
||||||
std::size_t operator()(object const& x) const
|
std::size_t operator()(object const& x) const
|
||||||
{
|
{
|
||||||
int result;
|
unsigned result;
|
||||||
switch (type_) {
|
switch (type_) {
|
||||||
case 1:
|
case 1:
|
||||||
result = x.tag1_;
|
result = static_cast<unsigned>(x.tag1_);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
result = x.tag2_;
|
result = static_cast<unsigned>(x.tag2_);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result = x.tag1_ + x.tag2_;
|
result =
|
||||||
|
static_cast<unsigned>(x.tag1_) + static_cast<unsigned>(x.tag2_);
|
||||||
}
|
}
|
||||||
return static_cast<std::size_t>(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t operator()(movable const& x) const
|
std::size_t operator()(movable const& x) const
|
||||||
{
|
{
|
||||||
int result;
|
unsigned result;
|
||||||
switch (type_) {
|
switch (type_) {
|
||||||
case 1:
|
case 1:
|
||||||
result = x.tag1_;
|
result = static_cast<unsigned>(x.tag1_);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
result = x.tag2_;
|
result = static_cast<unsigned>(x.tag2_);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
result = x.tag1_ + x.tag2_;
|
result =
|
||||||
|
static_cast<unsigned>(x.tag1_) + static_cast<unsigned>(x.tag2_);
|
||||||
}
|
}
|
||||||
return static_cast<std::size_t>(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t operator()(int x) const
|
std::size_t operator()(int x) const
|
||||||
|
Reference in New Issue
Block a user