diff --git a/test_conformance/conversions/conversions_data_info.h b/test_conformance/conversions/conversions_data_info.h index 8440c2c7..4f46a24e 100644 --- a/test_conformance/conversions/conversions_data_info.h +++ b/test_conformance/conversions/conversions_data_info.h @@ -408,7 +408,9 @@ void DataInfoSpec::conv(OutType *out, InType *in) // always convert to +0.0 } #else - *out = (*in == 0 ? 0.0 : (OutType)*in); + // Use volatile to prevent optimization by Clang compiler + volatile InType vi = *in; + *out = (vi == 0 ? 0.0 : static_cast(vi)); #endif } else if (std::is_same::value) @@ -467,12 +469,21 @@ void DataInfoSpec::conv(OutType *out, InType *in) else { if (std::is_same::value) - *out = (*in == 0 ? 0.f : *in); // Per IEEE-754-2008 5.4.1, 0's - // always convert to +0.0 + { + // Use volatile to prevent optimization by Clang compiler + volatile InType vi = *in; + // Per IEEE-754-2008 5.4.1, 0 always converts to +0.0 + *out = (vi == 0 ? 0.0f : vi); + } else if (std::is_same::value) + { + // Per IEEE-754-2008 5.4.1, 0 always converts to +0.0 *out = (*in == 0 ? 0.0 : *in); + } else + { *out = (OutType)*in; + } } }