================
@@ -2938,6 +2938,11 @@ void CStringChecker::evalMemset(CheckerContext &C,
   SVal SizeVal = C.getSVal(Size.Expression);
   QualType SizeTy = Size.Expression->getType();
 
+  // Avoid assertion failure in the corner case when we see a function named
+  // 'memset' with a nonstandard declaration.
+  if (!SizeTy->isUnsignedIntegerType())
----------------
NagyDonat wrote:

> In your test SizeTy is still an integer type. I think your guard only works 
> because it happens to be a signed integer type. If the parameter is const 
> unsigned & your check no longer catches it.

You were right, and I should've tested it with a `const unsigned &`.

> (Expressions of reference type simply don't exist. From the point of view of 
> the typechecker, the expression already refers to the glvalue behind the 
> reference.)

Good to know – I was not aware of this pitfall :sweat_smile: 

> But as a quick fix you can also check `Size.Expression->isPRValue()`. This 
> should be perfectly fine too.

I did so in 
https://github.com/llvm/llvm-project/pull/229119/commits/535eff24f7393be2e5546928f8e3905abab7a4cb.

https://github.com/llvm/llvm-project/pull/229119
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to