https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96435
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-10 branch has been updated by Iain Buclaw <ibuc...@gcc.gnu.org>: https://gcc.gnu.org/g:10490b7a453159f9b602b7f273f0aa6b4caebca7 commit r10-10012-g10490b7a453159f9b602b7f273f0aa6b4caebca7 Author: Iain Buclaw <ibuc...@gdcproject.org> Date: Mon Jul 26 19:28:02 2021 +0200 d: Ensure casting from bool results in either 0 or 1 (PR96435) If casting from bool, the result is either 0 or 1, any other value violates @safe code, so enforce that it is never invalid. PR d/96435 gcc/d/ChangeLog: * d-convert.cc (convert_for_rvalue): New function. * d-tree.h (convert_for_rvalue): Declare. * expr.cc (ExprVisitor::visit (CastExp *)): Use convert_for_rvalue. (build_return_dtor): Likewise. gcc/testsuite/ChangeLog: * gdc.dg/pr96435.d: New test. (cherry picked from commit 5c9b7408dc578cb2ae142a5c1b724c183497bdb2)