rsandifo-arm added a comment. In D76086#1920096 <https://reviews.llvm.org/D76086#1920096>, @efriedma wrote:
> Do we really want to forbid this? The expected semantics are clear, and the > obvious lowering to getelementptr just works. The problem is that pointer arithmetic is really a form of sizeof() operation. I.e. it only makes sense to move pointers past N objects if you know how big they are. One corner-case that behaves strangely without the patch is: void f() { int x; constexpr int y = (&x + 1) - &x; } void g() { __SVInt8_t x; constexpr int y = (&x + 1) - &x; } f() seems to be valid code, but g() produces: warning: subtraction of pointers to type '__SVInt8_t' of zero size has undefined behavior [-Wpointer-arith] So if we were to allow pointer arithmetic, I think in practice we'd need some rules to make sizeof effectively variable, but limited to that context. In practice I don't think a more relaxed rule wil be useful because it isn't possible to create arrays of sizeless type. So the simplest approach seems to be to inherit the normal rules for incomplete types. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76086/new/ https://reviews.llvm.org/D76086 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits