I just encountered the following code, where the first static_assert
will not fail if the templaterized pred1
is used, and in main x
is declared with an empty list of initializers. Is this something conforming to the standard, or is it a compiler bug? I am using g++ 6.4.1 on Fedora 25.
#include <cstdio>
template<class T> struct pred1 {
constexpr static bool value = false;
};
struct pred2 {
constexpr static bool value = false;
};
template<class A> struct align {
// this assertion only fails with align<int> x; but not with align<int> x();
static_assert( pred1<A>::value == true, "fail1" );
// this assertion will fail anyway
// static_assert( pred2::value == true, "fail2" );
};
int main() {
align<int> x; // this fails
align<int> x {}; // this fails too
align<int> x(); // this does not fail
return 0;
}