Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile error when serialize a more complicate struct to json when using clang 14.0.0-1ubuntu1 on ubuntu 22.04.1LTS #169

Open
cagev opened this issue May 25, 2023 · 2 comments

Comments

@cagev
Copy link

cagev commented May 25, 2023

在ubuntu22.04上使用 clang 14 编译 序列化一个更复杂的结构体到json会出现编译错误,
代码直接添加到json_example.cpp里了
https://github.com/cageq/iguana/blob/master/example/json_example.cpp

编译环境 wsl ubuntu 22.04.1 lts
cc --version
Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
c++ --version
Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

同样平台切换到gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0 没有问题, 感觉代码应该没问题,怀疑存在编译器兼容性问题。

编译错误如下:

[ 11%] Built target example
[ 16%] Building CXX object CMakeFiles/json_example.dir/example/json_example.cpp.o
In file included from /home/arthur/work/iguana/example/json_example.cpp:1:
In file included from /home/arthur/work/iguana/iguana/json_reader.hpp:5:
In file included from /home/arthur/work/iguana/iguana/reflection.hpp:23:
/home/arthur/work/iguana/iguana/detail/itoa.hpp:88:28: error: implicit instantiation of undefined template 'dec_::UT<0, 16>'
using U = typename UT<N,2*M,Ts...>::U;
^
/home/arthur/work/iguana/iguana/detail/itoa.hpp:88:28: note: in instantiation of template class 'dec_::UT<0, 8, dec_::MulInv<unsigned long, false, 12379400392853802749, 90>>' requested here
/home/arthur/work/iguana/iguana/detail/itoa.hpp:88:28: note: in instantiation of template class 'dec_::UT<0, 4, dec_::MulInv<unsigned int, false, 3518437209, 45>, dec_::MulInv<unsigned long, false, 12379400392853802749, 90>>' requested here
/home/arthur/work/iguana/iguana/detail/itoa.hpp:88:28: note: in instantiation of template class 'dec_::UT<0, 2, dec_::MulInv<unsigned short, true, 41943, 22>, dec_::MulInv<unsigned int, false, 3518437209, 45>, dec_::MulInv<unsigned long, false, 12379400392853802749, 90>>' requested here
/home/arthur/work/iguana/iguana/detail/itoa.hpp:90:21: note: in instantiation of template class 'dec_::UT<0, 1, dec_::MulInv<unsigned char, false, '\xcd', 11>, dec_::MulInv<unsigned short, true, 41943, 22>, dec_::MulInv<unsigned int, false, 3518437209, 45>, dec_::MulInv<unsigned long, false, 12379400392853802749, 90>>' requested here
template using MI = typename UT<N,1,
^
/home/arthur/work/iguana/iguana/detail/itoa.hpp:96:21: note: in instantiation of template type alias 'MI' requested here
template using U = typename MI::type;
^
/home/arthur/work/iguana/iguana/detail/itoa.hpp:194:51: note: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 to see all)
if (u < pow10<U>(N)) return head(p,U<N/2>(u));
^
/home/arthur/work/iguana/iguana/detail/itoa.hpp:256:38: note: in instantiation of function template specialization 'dec_::convert<dec_::Fwd>::itoa<unsigned char, 1UL>' requested here
p = convert::template itoa(p,u);
^
/home/arthur/work/iguana/iguana/detail/itoa.hpp:265:39: note: in instantiation of function template specialization 'dec_::convert<dec_::Fwd>::itoa<char, 1UL, nullptr>' requested here
return dec_::convert<dec_::Fwd>::itoa(i,p);
^
/home/arthur/work/iguana/iguana/json_writer.hpp:72:12: note: in instantiation of function template specialization 'itoa_fwd' requested here
auto p = itoa_fwd(value, temp);
^
/home/arthur/work/iguana/iguana/json_writer.hpp:262:16: note: in instantiation of function template specialization 'iguana::render_json_value<std::basic_string, char>' requested here
render_json_value(s, t.*v);
^
/home/arthur/work/iguana/example/json_example.cpp:213:11: note: in instantiation of function template specialization 'iguana::to_json<std::basic_string, FieldInfo &>' requested here
iguana::to_json(fieldInfo, ss);
^
/home/arthur/work/iguana/iguana/detail/itoa.hpp:85:41: note: template is declared here
template<int, int, class...> struct UT;
^
/home/arthur/work/iguana/iguana/detail/itoa.hpp:96:21: error: type 'MI<0>' (aka 'int') cannot be used prior to '::' because it has no members
template using U = typename MI::type;
^
/home/arthur/work/iguana/iguana/detail/itoa.hpp:102:9: note: in instantiation of template type alias 'U' requested here
U<N/2> r; // remainder with at most N decimal digits
^
/home/arthur/work/iguana/iguana/detail/itoa.hpp:195:23: note: in instantiation of template class 'dec_::QR<1>' requested here
QR x = split(u);
^
/home/arthur/work/iguana/iguana/detail/itoa.hpp:256:38: note: in instantiation of function template specialization 'dec_::convert<dec_::Fwd>::itoa<unsigned char, 1UL>' requested here
p = convert::template itoa(p,u);
^
/home/arthur/work/iguana/iguana/detail/itoa.hpp:265:39: note: in instantiation of function template specialization 'dec_::convert<dec_::Fwd>::itoa<char, 1UL, nullptr>' requested here
return dec_::convert<dec_::Fwd>::itoa(i,p);
^
/home/arthur/work/iguana/iguana/json_writer.hpp:72:12: note: in instantiation of function template specialization 'itoa_fwd' requested here
auto p = itoa_fwd(value, temp);
^
/home/arthur/work/iguana/iguana/json_writer.hpp:262:16: note: in instantiation of function template specialization 'iguana::render_json_value<std::basic_string, char>' requested here
render_json_value(s, t.*v);
^
/home/arthur/work/iguana/example/json_example.cpp:213:11: note: in instantiation of function template specialization 'iguana::to_json<std::basic_string, FieldInfo &>' requested here
iguana::to_json(fieldInfo, ss);
^
In file included from /home/arthur/work/iguana/example/json_example.cpp:1:
In file included from /home/arthur/work/iguana/iguana/json_reader.hpp:5:
In file included from /home/arthur/work/iguana/iguana/reflection.hpp:23:
/home/arthur/work/iguana/iguana/detail/itoa.hpp:96:21: error: type 'MI<0>' (aka 'int') cannot be used prior to '::' because it has no members
template using U = typename MI::type;
^
/home/arthur/work/iguana/iguana/detail/itoa.hpp:107:21: note: in instantiation of template type alias 'U' requested here
return { q, U<N/2>( u - q * pow10<U<N/2>>(N) ) };
^
/home/arthur/work/iguana/iguana/detail/itoa.hpp:195:23: note: in instantiation of function template specialization 'dec_::split<1UL>' requested here
QR x = split(u);
^
/home/arthur/work/iguana/iguana/detail/itoa.hpp:256:38: note: in instantiation of function template specialization 'dec_::convert<dec_::Fwd>::itoa<unsigned char, 1UL>' requested here
p = convert::template itoa(p,u);
^
/home/arthur/work/iguana/iguana/detail/itoa.hpp:265:39: note: in instantiation of function template specialization 'dec_::convert<dec_::Fwd>::itoa<char, 1UL, nullptr>' requested here
return dec_::convert<dec_::Fwd>::itoa(i,p);
^
/home/arthur/work/iguana/iguana/json_writer.hpp:72:12: note: in instantiation of function template specialization 'itoa_fwd' requested here
auto p = itoa_fwd(value, temp);
^
/home/arthur/work/iguana/iguana/json_writer.hpp:262:16: note: in instantiation of function template specialization 'iguana::render_json_value<std::basic_string, char>' requested here
render_json_value(s, t.*v);
^
/home/arthur/work/iguana/example/json_example.cpp:213:11: note: in instantiation of function template specialization 'iguana::to_json<std::basic_string, FieldInfo &>' requested here
iguana::to_json(fieldInfo, ss);
^
3 errors generated.
make[2]: *** [CMakeFiles/json_example.dir/build.make:76: CMakeFiles/json_example.dir/example/json_example.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:125: CMakeFiles/json_example.dir/all] Error 2
make: *** [Makefile:101: all] Error 2

@bbbgan
Copy link
Collaborator

bbbgan commented May 25, 2023

已经在最新的pr中修复,170

@qicosmos
Copy link
Owner

已经合并了。

171930433 pushed a commit to 171930433/iguana that referenced this issue Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants