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
This commit is contained in:
Alastair Murray
2020-09-30 11:06:45 +01:00
committed by GitHub
parent a41e5a9ee0
commit 26cacf056e

View File

@@ -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");
}