================ @@ -5992,6 +5992,15 @@ static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From, /*InOverloadResolution=*/false, /*AllowObjCWritebackConversion=*/false, /*AllowExplicit=*/false); + + // TryCopyInitialization returns incorrect info for attempts to bind reference + // to bit-field due to C++ [over.ics.ref]p4, so check it here. + if (From->refersToBitField() && T.getTypePtr()->isReferenceType()) { + return S.Diag(From->getBeginLoc(), + diag::err_reference_bind_to_bitfield_in_cce) + << From->getSourceRange(); + } ---------------- cor3ntin wrote:
I think the wording that makes it not a constant expression is > A [converted constant > expression](https://eel.is/c++draft/expr.const#def:expression,converted_constant) > of type T is an expression, implicitly converted to type T, where the > converted expression is a constant expression [...] where the reference > binding (if any) binds directly. Bitfields don't bind directly. It might be worth saying that in the comment https://github.com/llvm/llvm-project/pull/71077 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits