2020-01-23 Jason Merrill <jason@redhat.com>
+ PR c++/93331 - ICE with __builtin_strchr.
+ * constexpr.c (cxx_eval_builtin_function_call): Use the original
+ argument if we didn't manage to extract a STRING_CST.
+
PR c++/93345 - ICE with defaulted dtor and template.
PR c++/33799
* decl.c (cxx_maybe_build_cleanup): Don't try to set
for (i = 0; i < nargs; ++i)
{
tree arg = CALL_EXPR_ARG (t, i);
+ tree oarg = arg;
/* To handle string built-ins we need to pass ADDR_EXPR<STRING_CST> since
expand_builtin doesn't know how to look in the values table. */
arg = braced_lists_to_strings (TREE_TYPE (arg), arg);
if (TREE_CODE (arg) == STRING_CST)
arg = build_address (arg);
+ else
+ arg = oarg;
}
args[i] = arg;
--- /dev/null
+static const char s[] = "ab.cd.efghijk";
+
+int
+foo (const char *x)
+{
+ const char *a;
+ int b = 0;
+
+ a = __builtin_strchr (s, '.');
+ if (a == 0)
+ b = 1;
+ else if ((a = __builtin_strchr (a + 1, '.')) == 0)
+ b = 1;
+ else if (__builtin_strncmp (s, x, a - s))
+ b = 1;
+ else if (__builtin_strncmp (a + 1, x + (a - s + 1), 4) < 0)
+ b = 1;
+
+ if (b)
+ return 4;
+ return 0;
+}
+++ /dev/null
-static const char s[] = "ab.cd.efghijk";
-
-int
-foo (const char *x)
-{
- const char *a;
- int b = 0;
-
- a = __builtin_strchr (s, '.');
- if (a == 0)
- b = 1;
- else if ((a = __builtin_strchr (a + 1, '.')) == 0)
- b = 1;
- else if (__builtin_strncmp (s, x, a - s))
- b = 1;
- else if (__builtin_strncmp (a + 1, x + (a - s + 1), 4) < 0)
- b = 1;
-
- if (b)
- return 4;
- return 0;
-}