nikic wrote: > Do you know if this runs into issues with undefined behavior? I don't know > the exact rules, but remember reading something along the lines that some OOB > pointers cannot even be compared without running into UB. Having pointers > that don't respect type alignment sounds like walking on thin ice to me...
I think the relevant parts are https://eel.is/c++draft/expr.eq#3 (which does not specify UB for equality comparisons) and https://eel.is/c++draft/expr.reinterpret.cast#5 (which makes all non-roundtrip integer to pointer reinterpret_casts implementation-defined.) I think there are some more complexities here, but I think the gist is that as soon as we do a reinterpret_cast from an integer to a pointer we're in implementation-defined territory regardless of whether the resulting pointer is aligned or not. https://github.com/llvm/llvm-project/pull/146595 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits