<div> </div><div>Hello,</div><div> </div><div>02.12.2019, 22:56, "Henrik Grimler" <henrik@grimler.se>:</div><div> <div>> When I try to cross-compile 1.3.5 for android, with clang 8.0.7 (same</div><div>> with clang 9.0.0), it generates an intparam.h with:</div><div>></div><div>> #error "Integers of type int have no binary representation!!"</div><div>> #error "Integers of type long have no binary representation!!"</div><div>> #error "Integers of type long long have no binary</div><div>> representation!!"[...]</div><div>> #error "Integer types int and unsigned int have different sizes!!"</div><div>> #error "Integer types long and unsigned long have different sizes!!"</div><div>> #error "Integer types long long and unsigned long long have different</div><div>> sizes!!"</div><div>> #error "Type char * does not fit into an intptr_t!!"</div><div> </div><div>I've got the same error when cross-compiling for windows (with mingw64).</div><div> </div><div>> I do not get the same errors with 1.3.4. It seems to due to the</div><div>> typedef int[<negative>] -> static_assert</div><div>> change done in 2f7994014542920ad6ca726fbd8d023a5f49abc2. Reverting that</div><div>> commit makes the build succeed again.</div><div>></div><div>> If I compile the old type of test, everything works fine, so</div><div>></div><div>> int main()</div><div>> {<!-- --></div><div>>   typedef int verify[2*((int)((int)2 * (int)2 * (int)2 * (int)2 *</div><div>> (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 *</div><div>> (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 *</div><div>> (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 *</div><div>> (int)2 * (int)2 * (int)2 * (int)2) == 0) - 1];</div><div>>   ;</div><div>>   return 0;</div><div>> }</div><div>></div><div>> compiles without errors, while the same test with static_assert</div><div>></div><div>> int main()</div><div>> {<!-- --></div><div>>   static_assert((int)((int)2 * (int)2 * (int)2 * (int)2 * (int)2 *</div><div>> (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 *</div><div>> (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 *</div><div>> (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 * (int)2 *</div><div>> (int)2 * (int)2 * (int)2) == 0, "");</div><div>>   ;</div><div>>   return 0;</div><div>> }</div><div>></div><div>> fails with "test_new.cpp:3:17: error: static_assert expression is not</div><div>> an integral constant expression"</div><div> <div>This code relies on integer multiplication overflow to find out</div><div>the bit size of various integer types. However singed integer overflow</div><div>is an undefined behavior. Apparently in some contexts GCC uses mod 2^N</div><div>arithmetics to evaluate the signed integer expressions. As a result</div><div>`typedef int[2*((T)((T)2 * ... * (T)2) == 0) - 1]` trick works with both</div><div>signed and unsigned integers (and gives the correct result).</div><div> </div><div>Howerver GCC considers an expression involving an integer overflow as</div><div>a non-constant, and refuses to use it in `static_assert`</div><div> </div><div> </div></div><div>> I unfortunately do not know what the proper fix would be, but reverting</div><div>> 2f7994014542920ad6ca726fbd8d023a5f49abc2 makes the build succeed again</div><div>> at least.</div><div> </div><div>The proper fix is attached</div><div> </div><div>Hope this helps,</div><div>        Alexey</div></div>