| Issue |
110086
|
| Summary |
Inconsistent compilation behaviour between windows and ndk clang
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
sun-xm
|
Below code can be compiled with windows clang but not ndk clang:
/////////////////////////////////////
typedef struct _AType* AType;
template<typename T>
struct Test
{
T& operator[](size_t index)
{
return this->val[index];
}
// need to comment off below otherwise ambiguous operator[] error is reported in ndk
operator AType() const
{
return this->atype;
}
operator T*()
{
return this->val;
}
AType atype;
T val[10];
};
Test<int> t;
t[0]; // ambiguous operator[] error in ndk
Enviroment:
windows: win10 + vscode 1.93.1 + cmake 3.29.2 + clang 18.1.8
android: win10 + android studio 2024.1.1 Patch 1 + cmake 3.30.3 + ndk 27.1.12297006 (clang 18.0.2)
Error log in ndk:
C:\Users\xxx\AppData\Local\Android\Sdk\ndk\27.1.12297006\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=armv7-none-linux-androideabi24 --sysroot=C:/Users/xxx/AppData/Local/Android/Sdk/ndk/27.1.12297006/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Dopencl_EXPORTS -I.../app/src/main/cpp/../../../../../../../../Modules/OCL/Source -I.../app/src/main/cpp/../../../../../../../../Source/Common -I.../app/src/main/cpp/../../../../../../../../Source/OpenCL.Jni -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -std=c++11 -fno-limit-debug-info -fPIC -MD -MT CMakeFiles/opencl.dir/native-lib.cpp.o -MF CMakeFiles\opencl.dir\native-lib.cpp.o.d -o CMakeFiles/opencl.dir/native-lib.cpp.o -c .../app/src/main/cpp/native-lib.cpp
.../app/src/main/cpp/native-lib.cpp:95:6: error: use of overloaded operator '[]' is ambiguous (with operand types 'Test<int>' and 'int')
95 | t[0];
| ~^~
.../app/src/main/cpp/native-lib.cpp:66:8: note: candidate function
66 | T& operator[](size_t index)
| ^
.../app/src/main/cpp/native-lib.cpp:95:6: note: built-in candidate operator[](struct _AType *, int)
95 | t[0];
| ^
.../app/src/main/cpp/native-lib.cpp:95:6: note: built-in candidate operator[](const struct _AType *, int)
.../app/src/main/cpp/native-lib.cpp:95:6: note: built-in candidate operator[](volatile struct _AType *, int)
.../app/src/main/cpp/native-lib.cpp:95:6: note: built-in candidate operator[](const volatile struct _AType *, int)
.../app/src/main/cpp/native-lib.cpp:95:6: note: built-in candidate operator[](int *, int)
.../app/src/main/cpp/native-lib.cpp:95:6: note: built-in candidate operator[](const int *, int)
.../app/src/main/cpp/native-lib.cpp:95:6: note: built-in candidate operator[](volatile int *, int)
.../app/src/main/cpp/native-lib.cpp:95:6: note: built-in candidate operator[](const volatile int *, int)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs