Michael Paquier <mich...@paquier.xyz> writes: > The fun does not stop here. gcc is fine when using that for C and > C++: > #define StaticAssertStmt(condition, errmessage) \ > do { struct static_assert_struct { int static_assert_failure : (condition) > ? 1 : -1; }; } while(0) > #define StaticAssertExpr(condition, errmessage) \ > ((void) ({ StaticAssertStmt(condition, errmessage); }))
Hm, I'm not so sure. I just noticed that cpluspluscheck is failing for me now: $ src/tools/pginclude/cpluspluscheck In file included from /tmp/cpluspluscheck.HRgpVA/test.cpp:4: ./src/include/common/int128.h: In function 'void int128_add_int64_mul_int64(INT128*, int64, int64)': ./src/include/common/int128.h:180: error: types may not be defined in 'sizeof' expressions which of course is pointing at StaticAssertStmt(((int64) -1 >> 1) == (int64) -1, "arithmetic right shift is needed"); so the existing "C and C++" fallback StaticAssertStmt doesn't work for older g++. (This is g++ 4.4.7 from RHEL6.) > But then problems come from MSVC which does not like the do{} part for > statements, and this works: Huh? Surely do{} is a legal statement. Maybe we should just revert b7f64c64d instead of putting more time into this. It's looking like we're going to end up with four or so implementations no matter what, so it's getting hard to see any real benefit. regards, tom lane