@@ -213,4 +213,59 @@ void test_member_function_pointer_conversion() {
213213 bool l3 = l1; // NON_COMPLIANT
214214 bool l4 = l2; // NON_COMPLIANT
215215 bool l5 = (l1 != nullptr ); // COMPLIANT
216+ }
217+
218+ // Regression test for a false positive where the compiler-synthesized
219+ // `get<N>(...)` call used to implement structured binding decomposition (`auto
220+ // [a, b] = ...;`) was incorrectly flagged as a "conversion to bool", even
221+ // though the decomposed member is already `bool` - dereferencing a
222+ // `bool&`/`bool&&` reference is not a conversion from another type to `bool`.
223+ struct BoolPair {
224+ std::int32_t first;
225+ bool second;
226+ };
227+
228+ template <std::size_t I> auto get (const BoolPair &p) {
229+ if constexpr (I == 0 ) {
230+ return p.first ;
231+ } else {
232+ return p.second ;
233+ }
234+ }
235+
236+ namespace std {
237+ template <class T > struct tuple_size ;
238+ template <std::size_t I, class T > struct tuple_element ;
239+
240+ template <> struct tuple_size <BoolPair> {
241+ static constexpr std::size_t value = 2 ;
242+ };
243+ template <> struct tuple_element <0 , BoolPair> { using type = std::int32_t ; };
244+ template <> struct tuple_element <1 , BoolPair> { using type = bool ; };
245+ } // namespace std
246+
247+ BoolPair make_bool_pair ();
248+
249+ void test_structured_binding_bool_decomposition () {
250+ auto [l1, l2] =
251+ make_bool_pair (); // COMPLIANT - structured binding decomposition, not a
252+ // real conversion to bool
253+ if (l2) { // COMPLIANT
254+ }
255+ bool l3 = l2; // COMPLIANT - l2 is already bool
256+ }
257+
258+ // Regression test for a false positive where a `constexpr bool` variable
259+ // template, whose initializer is itself a dependent expression built from
260+ // another variable template, was incorrectly flagged as a "conversion from
261+ // 'unknown' to bool". The extractor cannot resolve a concrete type for a
262+ // dependent, uninstantiated template expression, so it should not be treated as
263+ // an actual conversion.
264+ template <typename T> constexpr bool is_something_v = true ;
265+
266+ template <typename T>
267+ constexpr bool derived_from_template_v = is_something_v<T>; // COMPLIANT
268+
269+ bool test_dependent_variable_template_instantiation () {
270+ return derived_from_template_v<std::int32_t >; // COMPLIANT
216271}
0 commit comments