On Mon, Jun 11, 2018 at 03:00:04PM -0400, Jason Merrill wrote: > On Wed, Jun 6, 2018 at 5:18 PM, Marek Polacek <pola...@redhat.com> wrote: > > We crash on this testcase containing a bogus attribute, because > > cp_check_const_attributes accessed TREE_VALUE of a tree that happened to be > > expr_pack_expansion. Since here we're merely trying to evaluate constexpr > > arguments, I thought we could skip such bogus arguments. > > Hmm, attributes should always be a TREE_LIST, lots of places assume > that. Why isn't the pack expansion wrapped in a TREE_LIST?
I believe you did that on purpose. There pack comes from cp_parser_std_attribute_list. We could wrap it into a TREE_LIST, but then tsubst_attribute would have to be tweaked to handle the pack expansion correctly. Since this is invalid code, it didn't seem worth it. Normally we remove the attribute in save_template_attributes: if (processing_template_decl) { if (check_for_bare_parameter_packs (attributes)) return; save_template_attributes (&attributes, decl, flags); } cp_check_const_attributes (attributes); so attributes is null after calling cp_check_const_attributes. But this test is invalid so save_template_attributes doesn't do anything and then cp_check_const_attributes crashes on the expr_pack_expansion. Marek