================
@@ -4238,7 +4238,8 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF,
   else
     elemTy = CGF.ConvertTypeForMem(elementType);
 
-  if (CGF.getLangOpts().PointerOverflowDefined)
+  if (CGF.getLangOpts().PointerOverflowDefined ||
+      CGF.isUnderlyingBasePointerConstantNull(pointerOperand))
----------------
dtcxzyw wrote:

> while this case only drops the inbounds, but still keeps the gep null, 
> resulting in a pointer with nullary provenance, so any loads/stores on it are 
> UB.

Unfortunately, the result of `__PTR_ALIGN` will be used to perform memory 
access :(
https://github.com/gcc-mirror/gcc/blob/79aa2a283a8d3327ff4d6dca77e81d5b1ac3a01e/libiberty/obstack.c#L213-L218

So this workaround doesn't address the real issue...


https://github.com/llvm/llvm-project/pull/137849
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to