[clang] [clang] Fix false warning on reinterpret_casting unknown template type (PR #109430)

Krystian Stasiowski via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 20 09:29:06 PDT 2024


================
@@ -2092,6 +2092,10 @@ void Sema::CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
     }
   }
 
+  if (SrcTy->isTemplateTypeParmType() || DestTy->isTemplateTypeParmType()) {
----------------
sdkrystian wrote:

This should probably be`if (SrcTy->isDependentType() || DestTy->isDependentType())`. Otherwise we will continue to warn for the following:
```cpp
template<typename T, typename U>
void f(T** x) {
  *reinterpret_cast<U**>(x);
}
```

https://github.com/llvm/llvm-project/pull/109430


More information about the cfe-commits mailing list