c++: avoid ICE with __builtin_memset (PR90997).
authorJason Merrill <jason@redhat.com>
Sun, 26 Jan 2020 05:25:19 +0000 (00:25 -0500)
committerJason Merrill <jason@redhat.com>
Sun, 26 Jan 2020 05:49:24 +0000 (00:49 -0500)
warn_for_memset calls fold_for_warn, which calls fold_non_dependent_expr, so
also calling instantiate_non_dependent_expr here is undesirable.

PR c++/90997
* semantics.c (finish_call_expr): Don't call
instantiate_non_dependent_expr before warn_for_memset.

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/g++.dg/ext/builtin14.C [new file with mode: 0644]

index 0dc1ad212286e2e3d09757124426c0cd286be7b6..0b17abae3a3d88cdf4ce4ef3640210e44ba0e89d 100644 (file)
@@ -1,3 +1,9 @@
+2020-01-26  Jason Merrill  <jason@redhat.com>
+
+       PR c++/90997
+       * semantics.c (finish_call_expr): Don't call
+       instantiate_non_dependent_expr before warn_for_memset.
+
 2020-01-25  Marek Polacek  <polacek@redhat.com>
 
        PR c++/93414 - poor diagnostic for dynamic_cast in constexpr context.
index 3b88f1520bc88e7b879b5acaa98b1f8276882531..a489e2cf3990331e5d18dba4f829041c9f8fde91 100644 (file)
@@ -2664,7 +2664,6 @@ finish_call_expr (tree fn, vec<tree, va_gc> **args, bool disallow_virtual,
              tree arg2 = (*orig_args)[2];
              int literal_mask = ((literal_integer_zerop (arg1) << 1)
                                  | (literal_integer_zerop (arg2) << 2));
-             arg2 = instantiate_non_dependent_expr (arg2);
              warn_for_memset (input_location, arg0, arg2, literal_mask);
            }
 
diff --git a/gcc/testsuite/g++.dg/ext/builtin14.C b/gcc/testsuite/g++.dg/ext/builtin14.C
new file mode 100644 (file)
index 0000000..38d5a39
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/90997
+
+template<class> void f ()
+{ __builtin_memset (0, 0, int(0.)); }