gcc/ChangeLog:
PR c++/98413
* builtins.c (get_offset_range): Avoid non-integers/-pointers.
gcc/testsuite/ChangeLog:
PR c++/98413
* g++.dg/warn/pr98413.C: New test.
x = TREE_OPERAND (x, 0);
tree type = TREE_TYPE (x);
+ if (!INTEGRAL_TYPE_P (type) && !POINTER_TYPE_P (type))
+ return false;
if (TREE_CODE (x) != INTEGER_CST
&& TREE_CODE (x) != SSA_NAME)
return false;
tree dealloc_decl = get_callee_fndecl (exp);
+
if (DECL_IS_OPERATOR_DELETE_P (dealloc_decl)
&& !DECL_IS_REPLACEABLE_OPERATOR (dealloc_decl))
{
--- /dev/null
+/* PR c++/98413 - ICE on placement new and member pointer
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+void* operator new (__SIZE_TYPE__, void *p) { return p; }
+
+struct A { int m; } a;
+
+void fc (int A::*p)
+{
+ new (&(a.*p)) char;
+}
+
+void fi (int A::*p)
+{
+ new (&(a.*p)) int;
+}
+
+void fB (int A::*p)
+{
+ struct B { int a[2]; };
+ new (&(a.*p)) B; // { dg-warning "\\\[-Wplacement-new" }
+}