Open ararmine opened 7 months ago
@llvm/issue-subscribers-clang-frontend
Author: None (ararmine)
This looks very similar to https://github.com/llvm/llvm-project/issues/12488 which was closed as won't fix.
CC @AaronBallman for second set of 👀
I think this is different -- this isn't an arbitrary reinterpret_cast
conversion, it's just a CK_AddressSpaceConversion
, which we could in principle permit in constant evaluation (perhaps just in this case, or perhaps in general). It'd be a bit of work to do, including IR generation changes, but probably not too hard.
I think the bigger problem is that the backend doesn't support these constants either: https://godbolt.org/z/4GW9cbenr
The following C++ code is not compiled with clang x86-64 v17.0.1 with MS extensions enabled, while it compiles successfully with X86 msvc v19.
Steps to reproduce:
typedef OpcUa_Void (__ptr32 PfnClear)(OpcUa_Void __ptr32);
template<class T, PfnClear fctClear> class UaStackTypeArray {};
OpcUa_Void ClearNothing(void* __ptr32);
template class UaStackTypeArray<bool, ClearNothing>;
test.cpp:12:39: error: non-type template argument is not a constant expression 12 | template class UaStackTypeArray<bool, ClearNothing>; | ^
~~~ test.cpp:12:39: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression 1 error generated.