Index: lib/Sema/SemaExprCXX.cpp =================================================================== --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -3426,8 +3426,12 @@ if (!ICS.UserDefined.EllipsisConversion) { // If the user-defined conversion is specified by a constructor, the // initial standard conversion sequence converts the source type to - // the type required by the argument of the constructor - BeforeToType = Ctor->getParamDecl(0)->getType().getNonReferenceType(); + // the type required by the argument of the constructor or the 'void' + // type if the argument has no constructors. + BeforeToType = + Ctor->param_empty() + ? Context.VoidTy + : Ctor->getParamDecl(0)->getType().getNonReferenceType(); } } // Watch out for ellipsis conversion. Index: test/SemaCXX/cxx11-crashes.cpp =================================================================== --- test/SemaCXX/cxx11-crashes.cpp +++ test/SemaCXX/cxx11-crashes.cpp @@ -91,3 +91,33 @@ Foo(lambda); } } + +namespace pr30664 { +struct foo { + int x; + foo() : x(42) { } +}; + +struct bar { + const foo &o; // expected-note {{reference member declared here}} + bar() : o{} {} // expected-warning {{binding reference member 'o' to a temporary value}} +}; + +struct outer { + struct inner { + const outer &o; // expected-note {{reference member declared here}} + inner() : o({}) {} // expected-warning {{binding reference member 'o' to a temporary value}} + }; +}; + +outer::inner i; + +struct foobar { + foobar(void) { } + struct inner { + int y; + const foobar &o; // expected-note {{reference member declared here}} + inner() : y(21), o({}) {} // expected-warning {{binding reference member 'o' to a temporary value}} + }; +}; +}