Skip to content

Compiler crashes on partial specialization of variable template with template template parameter #34301

Closed
@insertinterestingnamehere

Description

Bugzilla Link 34953
Version trunk
OS All
CC @DougGregor,@insertinterestingnamehere

Extended Description

This template is valid, and does compile with clang 3.9 and clang 5.0, but not with clang 4 or trunk. Trunk crashes, and clang 4 gives an error.
See also https://godbolt.org/g/NGQNCm.
Second similar example with structs further down.
To the best of my knowledge, both examples should be fine.

template <typename... param_types>
struct is_specified_instantiation_of {
  template <typename T, template <param_types...> class container>
  static constexpr bool value = false;

  template <template <param_types...> class container, param_types... params>
  static constexpr bool value<container<params...>, container> = true;

};

template <bool...>
struct bool_sequence {};

int main () {
  static_assert(is_specified_instantiation_of<bool, bool>::template 
    value<bool_sequence<true, false>, bool_sequence>, "");
}

A related example that compiles with 3.8 but either fails or crashes with later (crashes with trunk, see also https://godbolt.org/g/ZyTERb)

template <typename... param_types>
struct is_specified_instantiation_of {
  template <typename T, template <param_types...> class container>
  struct val {
    static constexpr bool value = false;
  };

  template <template <param_types...> class container, param_types... params>
  struct val<container<params...>, container> {
    static constexpr bool value = true;
  };
};

template <bool...>
struct bool_sequence {};

int main () {
  static_assert(is_specified_instantiation_of<bool, bool>::template 
    val<bool_sequence<true, false>, bool_sequence>::value, "");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partycrash-on-invalid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions