Index: lib/Sema/SemaExpr.cpp =================================================================== --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -1373,10 +1373,13 @@ // Decay and strip qualifiers for the controlling expression type, and handle // placeholder type replacement. See committee discussion from WG14 DR423. - ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr); - if (R.isInvalid()) - return ExprError(); - ControllingExpr = R.get(); + { + EnterExpressionEvaluationContext Unevaluated(*this, Sema::Unevaluated); + ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr); + if (R.isInvalid()) + return ExprError(); + ControllingExpr = R.get(); + } // The controlling expression is an unevaluated operand, so side effects are // likely unintended. Index: test/Sema/generic-selection.c =================================================================== --- test/Sema/generic-selection.c +++ test/Sema/generic-selection.c @@ -31,4 +31,8 @@ const int i = 12; int a9[_Generic(i, int: 1, default: 2) == 1 ? 1 : -1]; + + // This is expected to not trigger any diagnostics because the controlling + // expression is not evaluated. + (void)_Generic(*(int *)0, int: 1); }