This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix ubsan and C++14 constexpr ICEs (PR sanitizer/63956)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Thu, 20 Nov 2014 18:27:25 +0100
- Subject: Re: [PATCH] Fix ubsan and C++14 constexpr ICEs (PR sanitizer/63956)
- Authentication-results: sourceware.org; auth=none
- References: <20141120171452 dot GG29446 at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, Nov 20, 2014 at 06:14:52PM +0100, Marek Polacek wrote:
> This patch fixes a bunch of ICEs related to C++14 constexprs and
> -fsanitize=undefined. We should ignore ubsan internal functions
> and ubsan builtins in constexpr functions in cxx_eval_call_expression.
>
> Also add proper printing of internal functions into the C++ printer.
>
> Bootstrapped/regtested on ppc64-linux, ok for trunk?
I'd like Jason to review this. But a few nits:
> @@ -1171,6 +1182,10 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
> }
> if (DECL_CLONED_FUNCTION_P (fun))
> fun = DECL_CLONED_FUNCTION (fun);
> +
> + if (!current_function_decl && is_ubsan_builtin_p (fun))
> + return void_node;
> +
I don't understand the !current_function_decl here.
Also, looking at is_ubsan_builtin_p definition, I'd say
it should IMHO at least test DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
before comparing the function name, you can declare
__builtin_ubsan_foobarbaz () and use it and it won't be a builtin.
As for the testcase, I'd like to understand if C++ FE should reject
the constexpr functions when used with arguments that trigger undefined
behavior. But certainly the behavior should not depend on whether
-fsanitize=undefined or not.
Also, what is the reason for constexpr call flows off the end errors?
Shouldn't that be avoided if any error is found while interpreting the
function?
Jakub