Fix uninitialized values and bad enum conversions found by UBSAN.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@237738 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5486fac53c
commit
d539803d4b
test
libcxx/type_traits
std/atomics/atomics.flag
@ -57,7 +57,7 @@ void check_enum_types()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum enum1 {};
|
enum enum1 { zero = 0, one = 1 };
|
||||||
enum enum2 {
|
enum enum2 {
|
||||||
value = std::numeric_limits<unsigned long>::max()
|
value = std::numeric_limits<unsigned long>::max()
|
||||||
};
|
};
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
std::atomic_flag f;
|
std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
f.test_and_set();
|
f.test_and_set();
|
||||||
atomic_flag_clear(&f);
|
atomic_flag_clear(&f);
|
||||||
assert(f.test_and_set() == 0);
|
assert(f.test_and_set() == 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
volatile std::atomic_flag f;
|
volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
f.test_and_set();
|
f.test_and_set();
|
||||||
atomic_flag_clear(&f);
|
atomic_flag_clear(&f);
|
||||||
assert(f.test_and_set() == 0);
|
assert(f.test_and_set() == 0);
|
||||||
|
@ -22,37 +22,37 @@
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
std::atomic_flag f;
|
std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
f.test_and_set();
|
f.test_and_set();
|
||||||
atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
|
atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
|
||||||
assert(f.test_and_set() == 0);
|
assert(f.test_and_set() == 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::atomic_flag f;
|
std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
f.test_and_set();
|
f.test_and_set();
|
||||||
atomic_flag_clear_explicit(&f, std::memory_order_release);
|
atomic_flag_clear_explicit(&f, std::memory_order_release);
|
||||||
assert(f.test_and_set() == 0);
|
assert(f.test_and_set() == 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::atomic_flag f;
|
std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
f.test_and_set();
|
f.test_and_set();
|
||||||
atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
|
atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
|
||||||
assert(f.test_and_set() == 0);
|
assert(f.test_and_set() == 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
volatile std::atomic_flag f;
|
volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
f.test_and_set();
|
f.test_and_set();
|
||||||
atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
|
atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
|
||||||
assert(f.test_and_set() == 0);
|
assert(f.test_and_set() == 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
volatile std::atomic_flag f;
|
volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
f.test_and_set();
|
f.test_and_set();
|
||||||
atomic_flag_clear_explicit(&f, std::memory_order_release);
|
atomic_flag_clear_explicit(&f, std::memory_order_release);
|
||||||
assert(f.test_and_set() == 0);
|
assert(f.test_and_set() == 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
volatile std::atomic_flag f;
|
volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
f.test_and_set();
|
f.test_and_set();
|
||||||
atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
|
atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
|
||||||
assert(f.test_and_set() == 0);
|
assert(f.test_and_set() == 0);
|
||||||
|
@ -22,49 +22,49 @@
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
std::atomic_flag f;
|
std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
f.test_and_set();
|
f.test_and_set();
|
||||||
f.clear();
|
f.clear();
|
||||||
assert(f.test_and_set() == 0);
|
assert(f.test_and_set() == 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::atomic_flag f;
|
std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
f.test_and_set();
|
f.test_and_set();
|
||||||
f.clear(std::memory_order_relaxed);
|
f.clear(std::memory_order_relaxed);
|
||||||
assert(f.test_and_set() == 0);
|
assert(f.test_and_set() == 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::atomic_flag f;
|
std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
f.test_and_set();
|
f.test_and_set();
|
||||||
f.clear(std::memory_order_release);
|
f.clear(std::memory_order_release);
|
||||||
assert(f.test_and_set() == 0);
|
assert(f.test_and_set() == 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::atomic_flag f;
|
std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
f.test_and_set();
|
f.test_and_set();
|
||||||
f.clear(std::memory_order_seq_cst);
|
f.clear(std::memory_order_seq_cst);
|
||||||
assert(f.test_and_set() == 0);
|
assert(f.test_and_set() == 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
volatile std::atomic_flag f;
|
volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
f.test_and_set();
|
f.test_and_set();
|
||||||
f.clear();
|
f.clear();
|
||||||
assert(f.test_and_set() == 0);
|
assert(f.test_and_set() == 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
volatile std::atomic_flag f;
|
volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
f.test_and_set();
|
f.test_and_set();
|
||||||
f.clear(std::memory_order_relaxed);
|
f.clear(std::memory_order_relaxed);
|
||||||
assert(f.test_and_set() == 0);
|
assert(f.test_and_set() == 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
volatile std::atomic_flag f;
|
volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
f.test_and_set();
|
f.test_and_set();
|
||||||
f.clear(std::memory_order_release);
|
f.clear(std::memory_order_release);
|
||||||
assert(f.test_and_set() == 0);
|
assert(f.test_and_set() == 0);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
volatile std::atomic_flag f;
|
volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
|
||||||
f.test_and_set();
|
f.test_and_set();
|
||||||
f.clear(std::memory_order_seq_cst);
|
f.clear(std::memory_order_seq_cst);
|
||||||
assert(f.test_and_set() == 0);
|
assert(f.test_and_set() == 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user