https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116673
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- Something like this: --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -13396,11 +13396,20 @@ finish_builtin_launder (location_t loc, tree arg, tsubst_flags_t complain) arg = decay_conversion (arg, complain); if (error_operand_p (arg)) return error_mark_node; - if (!type_dependent_expression_p (arg) - && !TYPE_PTR_P (TREE_TYPE (arg))) + if (!type_dependent_expression_p (arg)) { - error_at (loc, "non-pointer argument to %<__builtin_launder%>"); - return error_mark_node; + tree type = TREE_TYPE (arg); + if (!TYPE_PTR_P (type)) + { + error_at (loc, "non-pointer argument to %<__builtin_launder%>"); + return error_mark_node; + } + else if (!object_type_p (TREE_TYPE (type))) + { + // std::launder is ill-formed for function and cv void pointers. + error_at (loc, "invalid argument to %<__builtin_launder%>"); + return error_mark_node; + } } if (processing_template_decl) arg = orig_arg;