On Thu, Jul 08, 2021 at 09:30:27AM -0400, Jason Merrill wrote: > On 7/7/21 9:40 PM, Marek Polacek wrote: > > It sounds plausible that this assert > > > > int f(); > > static_assert(noexcept(sizeof(f()))); > > > > should pass: sizeof produces a std::size_t and its operand is not > > evaluated, so it can't throw. noexcept should only evaluate to > > false for potentially evaluated operands. Therefore I think that > > check_noexcept_r shouldn't walk into operands of sizeof/decltype/ > > alignof/typeof. Only checking cp_unevaluated_operand therein does > > not work, because expr_noexcept_p can be called in an unevaluated > > context, so I resorted to the following cp_evaluated hack. Does > > that seem acceptable? > > I suppose, but why not check for SIZEOF_EXPR/ALIGNOF_EXPR/NOEXCEPT_EXPR > directly?
I thought I would, but then it occurred to me that it might be better to rely on cp_walk_subtrees which ++/--s cp_unevaluated_operand for those codes. I'd be happy to change the patch to check those codes directly; maybe I'm overthinking things here. -- Marek Polacek • Red Hat, Inc. • 300 A St, Boston, MA