Index: lib/AST/ExprConstant.cpp =================================================================== --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -7022,11 +7022,9 @@ } case Builtin::BIstrlen: - // A call to strlen is not a constant expression. - if (Info.getLangOpts().CPlusPlus11) - Info.CCEDiag(E, diag::note_constexpr_invalid_function) - << /*isConstexpr*/0 << /*isConstructor*/0 << "'strlen'"; - else + // As a GCC compatibility extension, we support strlen() + // as a constant expression. + if (!Info.getLangOpts().CPlusPlus11) Info.CCEDiag(E, diag::note_invalid_subexpr_in_const_expr); // Fall through. case Builtin::BI__builtin_strlen: { Index: test/SemaCXX/constexpr-strlen.cpp =================================================================== --- test/SemaCXX/constexpr-strlen.cpp +++ test/SemaCXX/constexpr-strlen.cpp @@ -8,7 +8,7 @@ # 10 "SemaCXX/constexpr-strlen.cpp" 2 constexpr int n = __builtin_strlen("hello"); // ok -constexpr int m = strlen("hello"); // expected-error {{constant expression}} expected-note {{non-constexpr function 'strlen' cannot be used in a constant expression}} +constexpr int m = strlen("hello"); // ok // Make sure we can evaluate a call to strlen. int arr[3]; // expected-note {{here}}