This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/70172] incorrect reinterpret_cast from integer to pointer error on invalid constexpr initialization
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 10 Mar 2016 20:00:24 +0000
- Subject: [Bug c++/70172] incorrect reinterpret_cast from integer to pointer error on invalid constexpr initialization
- Auto-submitted: auto-generated
- References: <bug-70172-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70172
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Blocks| |55004
Known to fail| |6.0
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
I would normally make the Severity of a bug in the text of a diagnostic minor
but this one seems like it's more than a poorly phrased diagnostic. The code
that triggers the error is in the potential_constant_expression_1() function in
constexp.c:
case NOP_EXPR:
case CONVERT_EXPR:
case VIEW_CONVERT_EXPR:
/* -- a reinterpret_cast. FIXME not implemented, and this rule
may change to something more specific to type-punning (DR 1312). */
{
tree from = TREE_OPERAND (t, 0);
if (POINTER_TYPE_P (TREE_TYPE (t))
&& TREE_CODE (from) == INTEGER_CST
&& !integer_zerop (from))
{
if (flags & tf_error)
error_at (EXPR_LOC_OR_LOC (t, input_location),
"reinterpret_cast from integer to pointer");
return false;
}
return (RECUR (from, TREE_CODE (t) != VIEW_CONVERT_EXPR));
}
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55004
[Bug 55004] [meta-bug] constexpr issues