[Bug c++/83273] if constexpr does not fail with run-time conditions
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Dec 4 17:37:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83273
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |jason at gcc dot gnu.org,
| |nathan at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
tree
finish_if_stmt_cond (tree cond, tree if_stmt)
{
cond = maybe_convert_cond (cond);
if (IF_STMT_CONSTEXPR_P (if_stmt)
&& is_constant_expression (cond)
&& !value_dependent_expression_p (cond))
{
cond = instantiate_non_dependent_expr (cond);
cond = cxx_constant_value (cond, NULL_TREE);
}
So, if is_constant_expression is true, we do the right thing.
There is just no diagnostics if cond fails the is_constant_expression check and
isn't value dependent. We actually treat that if constexpr like normal if,
with both then and else evaluated.
More information about the Gcc-bugs
mailing list