Why static_assert in template gives me different result with equivalent expressions?
I've noticed strange behavior of static_assert : #include <iostream> template <typename T, unsigned int D> struct Vec { static_assert(D && 0, "Invalid dimension for vector!"); }; template <typename T> struct Vec<T, 1> {union {T x, r;};}; template <typename T> struct Vec<T, 2> : Vec<T, 1> {union {T y, g;};}; template <typename T> struct Vec<T, 3> : Vec<T, 2> {union {T z, b;};}; template <typename T> struct Vec<T, 4> : Vec<T, 3> {union {T w, a;};}; int main() { Vec<float, 3> v; v.x = 1; v.y = 2; v.z = 3; return 0; } It compiles fine: http://ideone.com/wHbJYP . I would expect static_assert(0,