[PATCH] D26196: [WIP] Add support for non-zero null pointers

John McCall via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 7 15:30:32 PST 2016


rjmccall added inline comments.


================
Comment at: lib/CodeGen/CGExprConstant.cpp:1340
+          return C;
+        return getNullPtr(PT, DestType);
       }
----------------
efriedma wrote:
> Consider code like the following:
> 
>     int x = 0;
>     auto y1 = (__specialaddrspace int*)0;
>     auto y2 = (__specialaddrspace int*)((void)0, 0);
>     auto y3 = (__specialaddrspace int*)x;
> 
> How do you expect these three cases to behave?  (The first case involves a C null pointer constant, the second and third cases are different ways of writing a general int->ptr conversion.)
Yeah, I think you probably need to fix APValue to be unambiguous about whether the value is a formal null pointer (CK_NullToPointer) or just a cast of an integer (CK_IntegralToPointer).  It looks like PointerExprEvaluator will generate the exact same value for both.


https://reviews.llvm.org/D26196





More information about the cfe-commits mailing list