https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81157
Bug ID: 81157 Summary: If constexpr does not support Short-circuit evaluation Product: gcc Version: 7.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: kmp53 at sina dot com Target Milestone: --- template <typename T,typename U> concept bool Same=std::is_same_v<T,U>; template<typename T> concept bool IsContainer=requires(T t){ t.cnt(); typename T::innerType; }; struct Ct { void cnt(){;} using innerType=int; }; template<class V> requires IsContainer<V>&&Same<typename V::innerType,int>||Same<V,int> void fn(const V &a) { void fn(const V &a) { if constexpr(IsContainer<V>&&Same<typename V::innerType,int>) ;//① //if constexpr(IsContainer<V>)//② //if constexpr(Same<typename V::innerType,int>) ; else if (Same<V,int>) ; } int main(int argc,char*argv[]){ fn(1);//ill-formed fn(Ct());//OK } Concept supports short expressions, while if constexpr does not. When I write ①, there is an error 'int' is not a class, struct, or union type If it is written ②, there will be no problem. Is it a bug or a defect?