[cfe-dev] Crash on conditional operation with address_space pointer
Leonard Chan via cfe-dev
cfe-dev at lists.llvm.org
Fri Aug 3 16:03:53 PDT 2018
Compiling the following causes clang to crash
char *cmp(__attribute__((address_space(1))) char *x,
__attribute__((address_space(2))) char *y) {
return x < y ? x : y;
}
with the message: "wrong cast for pointers in different address
spaces(must be an address space cast)!"
The problem seems to be that BitCast is used when
AddressSpaceConversion should be used instead when casting the `y` to
a void *. The error is thrown during code gen where a BitCast expects
the source and dest address space to be the same.
I submitted a patch (https://reviews.llvm.org/D50278) for a fix where
we check for differing address spaces in the operands and perform an
AddressSpaceConversion cast if anyone wants to review it. It seems
that AddressSpaceConversions though were only available when using
OpenCL. I'm not familiar with OpenCL and not sure if this was
intended, but it fixes the crash while still retaining the warning of
using mismatched pointers and all the clang tests pass.
- Leo
More information about the cfe-dev
mailing list