This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Hi,
  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.

Thanks,
Andrew Pinski

ChangeLog:

* 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.

Attachment: fixpr36695.diff.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]