https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92530
Bug ID: 92530 Summary: Absent error on static_assert expression Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: pkeir at outlook dot com Target Milestone: --- Created attachment 47272 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47272&action=edit The code described in the bug report. The static_assert expression in the C++11 code below is not an integral constant expression. GCC trunk compiles this, while Clang reports the error correctly. To quote Clang's Richard Smith: "The evaluation semantics of the expression 'x' (because it's of reference type) involve locating the object that the reference binds to, which can't be done in this case because we don't know the value of the function parameter 'x'. So the evaluation of the static_assert condition is non-constant, which is invalid." The language rule that's violated is here: http://eel.is/c++draft/expr.const#4.12 template <typename T> constexpr bool bar(T &) { return true; } template <typename T> constexpr bool foo(T &x) { static_assert(bar(x),""); return bar(x); } int main(int argc, char *argv[]) { int i; constexpr bool y = foo(i); return 0; }