Closed josephinius closed 3 days ago
The first one can be resolved by explicit casting.
error: implicit conversion from '_Complex double' to 'double' is not permitted in C++
od[0] *= (cytnx_complex128)_Rin[i * N + i];
Can you tell me where it occurs?
Here is a related fix https://github.com/tfhe/tfhe/issues/213
Here are the whole error messages:
/Cytnx/src/backend/linalg_internal_cpu/Det_internal.cpp:31:36: error: implicit conversion from '_Complex double' to 'double' is not permitted in C++
od[0] *= (cytnx_complex128)_Rin[i * N + i];
~ ^~~~~~~~~~~~~~~
/Cytnx/src/backend/linalg_internal_cpu/Det_internal.cpp:55:35: error: implicit conversion from '_Complex float' to 'float' is not permitted in C++
od[0] *= (cytnx_complex64)_Rin[i * N + i];
no-c++11-narrowing
problem. For the implicit conversion, I can't reproduce the error while using clang++. @josephinius, does the error still happen?with commit 0be640dcb08dcfd4de8ed9a2f7da73dec7ddfaf2 and clang version: -- The CXX compiler identification is AppleClang 15.0.0.15000309 -- The C compiler identification is AppleClang 15.0.0.15000309
I still encounter this
[ 83%] Building CXX object CMakeFiles/cytnx.dir/src/backend/linalg_internal_cpu/Ger_internal.cpp.o
/Users/pcchen/github/Cytnx/src/backend/linalg_internal_cpu/Det_internal.cpp:31:36: error: implicit conversion from '_Complex double' to 'double' is not permitted in C++
od[0] *= (cytnx_complex128)_Rin[i * N + i];
~ ^~~~~~~~~~~~~~~
/Users/pcchen/github/Cytnx/src/backend/linalg_internal_cpu/Det_internal.cpp:55:35: error: implicit conversion from '_Complex float' to 'float' is not permitted in C++
od[0] *= (cytnx_complex64)_Rin[i * N + i];
~ ^~~~~~~~~~~~~~~
2 errors generated.
A solution was given in #461. I am not sure if the change really suppress the error of invalid conversion because I cannot reproduce on CentOS with clang and the online clang compiler either.
Someone who has Mac can try to build the code below with clang++ and see if it can be successfully compiled. If it is not passed, there may be a bug in Mac's clang.
#include <complex.h>
#include <iostream>
#include <complex>
int main() {
double _Complex c_type_right = 123.4 + 45435.1I;
std::complex<double> cpp_type_right{23, 23};
std::complex<double> left{43.4, 2532.1};
left *= (std::complex<double>)c_type_right;
left *= (std::complex<double>)cpp_type_right;
std::cout << std::complex<float>{c_type_right} << std::endl;
}
@IvanaGyro I tried to compile the code
#include <complex.h>
#include <iostream>
#include <complex>
int main() {
double _Complex c_type_right = 123.4 + 45435.1I;
std::complex<double> cpp_type_right{23, 23};
std::complex<double> left{43.4, 2532.1};
left *= (std::complex<double>)c_type_right;
left *= (std::complex<double>)cpp_type_right;
std::cout << std::complex<float>{c_type_right} << std::endl;
}
using Apple clang version 15.0.0 (clang-1500.3.9.4); I got the error:
complex_example.cpp:10:35: error: implicit conversion from '_Complex double' to 'double' is not permitted in C++
left *= (std::complex~~~
complex_example.cpp:13:38: error: implicit conversion from '_Complex double' to 'float' is not permitted in C++
std::cout << std::complex
2 errors generated.
It seems that #461 has resolve this issue. Apple Clang missed some features. We may consider not to support Apple Clang.
Which c++ version are we targeting? I would suggest target C++24 (don't use anything that is too new)
And If to possible please write the code that could cover most of the compilers ( specifically clang has more restrictions compared to g++, so I suggest to target clang when developing).
Also. Apple's clang (Apple clang) is different from the typical clang. The behavior is different from the clang one installs on Mac via homebrew.......
First, I had to add
add_compile_options(-Wno-c++11-narrowing)
into CMakeLists.txt to get rid of this error:But I still have the following error while installing:
I use clang as a compiler.