From d539803d4bedba05e509d70de82db49f1c001828 Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric@efcs.ca>
Date: Tue, 19 May 2015 23:03:57 +0000
Subject: [PATCH] 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
---
 .../type_traits/convert_to_integral.pass.cpp     |  2 +-
 .../atomics.flag/atomic_flag_clear.pass.cpp      |  4 ++--
 .../atomic_flag_clear_explicit.pass.cpp          | 12 ++++++------
 test/std/atomics/atomics.flag/clear.pass.cpp     | 16 ++++++++--------
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/test/libcxx/type_traits/convert_to_integral.pass.cpp b/test/libcxx/type_traits/convert_to_integral.pass.cpp
index 37060a05..34e43c44 100644
--- a/test/libcxx/type_traits/convert_to_integral.pass.cpp
+++ b/test/libcxx/type_traits/convert_to_integral.pass.cpp
@@ -57,7 +57,7 @@ void check_enum_types()
 }
 
 
-enum enum1 {};
+enum enum1 { zero = 0, one = 1 };
 enum enum2 {
   value = std::numeric_limits<unsigned long>::max()
 };
diff --git a/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp b/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
index 64093d63..8a60f819 100644
--- a/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
+++ b/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
@@ -22,13 +22,13 @@
 int main()
 {
     {
-        std::atomic_flag f;
+        std::atomic_flag f = ATOMIC_FLAG_INIT;
         f.test_and_set();
         atomic_flag_clear(&f);
         assert(f.test_and_set() == 0);
     }
     {
-        volatile std::atomic_flag f;
+        volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
         f.test_and_set();
         atomic_flag_clear(&f);
         assert(f.test_and_set() == 0);
diff --git a/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp b/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
index e1a9349c..92e57ecc 100644
--- a/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
+++ b/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
@@ -22,37 +22,37 @@
 int main()
 {
     {
-        std::atomic_flag f;
+        std::atomic_flag f = ATOMIC_FLAG_INIT;
         f.test_and_set();
         atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
         assert(f.test_and_set() == 0);
     }
     {
-        std::atomic_flag f;
+        std::atomic_flag f = ATOMIC_FLAG_INIT;
         f.test_and_set();
         atomic_flag_clear_explicit(&f, std::memory_order_release);
         assert(f.test_and_set() == 0);
     }
     {
-        std::atomic_flag f;
+        std::atomic_flag f = ATOMIC_FLAG_INIT;
         f.test_and_set();
         atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
         assert(f.test_and_set() == 0);
     }
     {
-        volatile std::atomic_flag f;
+        volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
         f.test_and_set();
         atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
         assert(f.test_and_set() == 0);
     }
     {
-        volatile std::atomic_flag f;
+        volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
         f.test_and_set();
         atomic_flag_clear_explicit(&f, std::memory_order_release);
         assert(f.test_and_set() == 0);
     }
     {
-        volatile std::atomic_flag f;
+        volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
         f.test_and_set();
         atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
         assert(f.test_and_set() == 0);
diff --git a/test/std/atomics/atomics.flag/clear.pass.cpp b/test/std/atomics/atomics.flag/clear.pass.cpp
index 65051af7..7c936268 100644
--- a/test/std/atomics/atomics.flag/clear.pass.cpp
+++ b/test/std/atomics/atomics.flag/clear.pass.cpp
@@ -22,49 +22,49 @@
 int main()
 {
     {
-        std::atomic_flag f;
+        std::atomic_flag f = ATOMIC_FLAG_INIT;
         f.test_and_set();
         f.clear();
         assert(f.test_and_set() == 0);
     }
     {
-        std::atomic_flag f;
+        std::atomic_flag f = ATOMIC_FLAG_INIT;
         f.test_and_set();
         f.clear(std::memory_order_relaxed);
         assert(f.test_and_set() == 0);
     }
     {
-        std::atomic_flag f;
+        std::atomic_flag f = ATOMIC_FLAG_INIT;
         f.test_and_set();
         f.clear(std::memory_order_release);
         assert(f.test_and_set() == 0);
     }
     {
-        std::atomic_flag f;
+        std::atomic_flag f = ATOMIC_FLAG_INIT;
         f.test_and_set();
         f.clear(std::memory_order_seq_cst);
         assert(f.test_and_set() == 0);
     }
     {
-        volatile std::atomic_flag f;
+        volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
         f.test_and_set();
         f.clear();
         assert(f.test_and_set() == 0);
     }
     {
-        volatile std::atomic_flag f;
+        volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
         f.test_and_set();
         f.clear(std::memory_order_relaxed);
         assert(f.test_and_set() == 0);
     }
     {
-        volatile std::atomic_flag f;
+        volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
         f.test_and_set();
         f.clear(std::memory_order_release);
         assert(f.test_and_set() == 0);
     }
     {
-        volatile std::atomic_flag f;
+        volatile std::atomic_flag f = ATOMIC_FLAG_INIT;
         f.test_and_set();
         f.clear(std::memory_order_seq_cst);
         assert(f.test_and_set() == 0);