[Bug c++/68810] [6 regression] FAIL: g++.dg/cpp0x/constexpr-reinterpret1.C -- test for errors -- -m32
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jan 12 18:53:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68810
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The reason for this is cp_convert_to_pointer doing:
228 if (INTEGRAL_CODE_P (form))
229 {
230 if (TYPE_PRECISION (intype) == POINTER_SIZE)
231 return build1 (CONVERT_EXPR, type, expr);
232 expr = cp_convert (c_common_type_for_size (POINTER_SIZE, 0),
expr,
233 complain);
234 /* Modes may be different but sizes should be the same. There
235 is supposed to be some integral type that is the same width
236 as a pointer. */
237 gcc_assert (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (expr)))
238 == GET_MODE_SIZE (TYPE_MODE (type)));
239
240 return convert_to_pointer_nofold (type, expr);
241 }
expr is INTEGER_CST 4, so for sizeof (void *) == sizeof (int) targets it
unconditionally creates unfolded CONVERT_EXPR, which will hold the current
input_location at that point (happens to be about right), while for sizeof
(void *) != sizeof (int) targets it goes different path and (what happened to
delayed folding here?) cp_convert actually folds it right away into long int 4L
INTEGER_CST and convert_to_pointer_nofold (regardless of the *_nofold in the
name) actually also folds it into INTEGER_CST 4 with pointer type.
Thus, unless we progress further with actual delayed folding, and/or unless we
introduce also USE_EXPR trees holding uses of constants and decls, we are not
going to resolve this.
So, for GCC6, I think best would be just to move the }:
--- constexpr-reinterpret1.C~ 2015-11-14 19:35:49.000000000 +0100
+++ constexpr-reinterpret1.C 2016-01-12 19:52:00.114998687 +0100
@@ -17,8 +17,7 @@ public:
constexpr static Inner & getInner()
{
/* I am surprised this is considered a constexpr */
- return *((Inner *)4);
- } // { dg-error "reinterpret_cast" "" }
+ return *((Inner *)4); } // { dg-error "reinterpret_cast" "" }
};
B B::instance;
so that it really doesn't matter where it is reported. And work more on C++
delayed folding for GCC 7.
More information about the Gcc-bugs
mailing list