From 26cacf056eb26a34d5cf870e6cc1df5d52922721 Mon Sep 17 00:00:00 2001 From: Alastair Murray Date: Wed, 30 Sep 2020 11:06:45 +0100 Subject: [PATCH] Fail feature macro compare if compiler has more features than runtime (#982) * Fail feature macro compare if compiler has more features than runtime Because a C++11 `std::equal` only iterates over the first container, and matches with items in the second, if the second container contains more items the check can still pass even though they're not identical. Just use `==` instead. Fixes #979 * Move an expression to its point of use --- test_conformance/compiler/test_feature_macro.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test_conformance/compiler/test_feature_macro.cpp b/test_conformance/compiler/test_feature_macro.cpp index cea85a6e..1dd3549b 100644 --- a/test_conformance/compiler/test_feature_macro.cpp +++ b/test_conformance/compiler/test_feature_macro.cpp @@ -22,7 +22,7 @@ const char* macro_supported_source = R"(kernel void enabled(global int * buf) { int n = get_global_id(0); buf[n] = 0; #ifndef %s - ERROR; + #error Feature macro was not defined #endif })"; @@ -31,7 +31,7 @@ const char* macro_not_supported_source = int n = get_global_id(0); buf[n] = 0; #ifdef %s - ERROR; + #error Feature macro was defined #endif })"; @@ -686,10 +686,7 @@ int test_consistency_c_features_list(cl_device_id deviceID, sort(vec_to_cmp.begin(), vec_to_cmp.end()); sort(vec_device_feature_names.begin(), vec_device_feature_names.end()); - cl_bool result = - std::equal(vec_device_feature_names.begin(), - vec_device_feature_names.end(), vec_to_cmp.begin()); - if (result) + if (vec_device_feature_names == vec_to_cmp) { log_info("Comparison list of features - passed\n"); }