bytedance / sonic-cpp

A fast JSON serializing & deserializing library, accelerated by SIMD.
Apache License 2.0
835 stars 101 forks source link

error "__builtin_uaddll_overflow’在此作用域中尚未声明" #74

Open giobyhu opened 1 year ago

giobyhu commented 1 year ago

__builtin_uaddll_overflow’在此作用域中尚未声明

giobyhu commented 1 year ago

sonic/include/sonic/internal/arch/avx2/simd.h:50:49: 错误:不能在初始化时将‘m128i {aka vector(2) long long int}’转换为‘long long int’ sonic_force_inline base128() : value{__m128i()} {}

__builtin_uaddll_overflow’在此作用域中尚未声明

-mavx2 -mpclmul -mbmi都加了

giobyhu commented 1 year ago

sonic_force_inline base128() : value{__m128i()} {} 改为 sonic_force_inline base128() : value(_mm_setzero_si128()) {} sonic_force_inline base256() : value{m256i()} {} 改为 sonic_force_inline base256() : value(_mm256_setzero_si256()) {} sonic_force_inline bool AddOverflow(uint64_t value1, uint64_t value2, uint64_t* result) { return builtin_uaddll_overflow( value1, value2, reinterpret_cast<unsigned long long>(result)); } 改为 sonic_force_inline bool AddOverflow(uint64_t value1, uint64_t value2, uint64_t result) { if (value1 > std::numeric_limits::max() - value2) { // Overflow would occur return true; } result = value1 + value2; return false; //return __builtin_uaddll_overflow( //value1, value2, reinterpret_cast<unsigned long long>(result)); } 临时解决编译不通过的问题

liuq19 commented 1 year ago

感谢反馈,看起来是环境中该编译器不支持 __builtin_uaddll_overflow 扩展

giobyhu commented 1 year ago

@liuq19 还有一个问题,不知道有没有人反馈过。首页-usage-Getting and Setting-print_member 写的是sonic_json::Node& key = m->name; 编译出错 example里写的是const sonic_json::Node& key = m->name;

liuq19 commented 1 year ago

正确应该是 const sonic_json::Node& key = m->name, 目的是防止用户将 object 暴露的 key set 成非string的类型,后续我们会更新readme,感谢~

@liuq19 还有一个问题,不知道有没有人反馈过。首页-usage-Getting and Setting-print_member 写的是sonic_json::Node& key = m->name; 编译出错 example里写的是const sonic_json::Node& key = m->name;

xiegx94 commented 1 year ago

@liuq19 还有一个问题,不知道有没有人反馈过。首页-usage-Getting and Setting-print_member 写的是sonic_json::Node& key = m->name; 编译出错 example里写的是const sonic_json::Node& key = m->name;

fixed #79

qshanz373 commented 11 months ago

感谢反馈,看起来是环境中该编译器不支持 __builtin_uaddll_overflow 扩展

编译器有个内置的函数来 check builtin 是否支持,我们可以加上这个 check,这样可以更友好的提前暴露这个问题?