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