[PATCH] Fix PR 36695, Value-initialization of reference type is allowed

Andrew Pinski pinskia@gmail.com
Thu Jan 1 20:53:00 GMT 2009

  The problem is that after the patch to fix PR 21210, we would accept
default-initialization of a reference type as we would just call
cp_convert instead of calling the build_c_cast which was able to error
out when converting 0 to a reference type.
This patch fixes the problem by adding a check for reference types and
a null parameter.  This is done before processing template decls so we
can diagnostic the invalid code even without instantiating the
function (which is even better than what was happening before the fix
for PR 21210).

I also added more testcases for PR 21210 to make sure it does not regress again.

OK? Bootstrapped and tested on i686-linux-gnu with no regressions.

Andrew Pinski


* typeck2.c (build_functional_cast): Check for reference type and NULL PARMS.

* g++.dg/ext/complex4.C: New test.
* g++.dg/ext/complex5.C: New test.
* g++.dg/init/reference1.C: New test.
* g++.dg/init/reference2.C: New test.
* g++.dg/init/reference3.C: New test.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fixpr36695.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090101/3ffb4b24/attachment.txt>

More information about the Gcc-patches mailing list