Skip to content

[expr.new] Template VS non-template deallocation functions #839

@frederick-vs-ja

Description

@frederick-vs-ja

Full name of submitter (unless configured in github; will be published with the issue): Jiang An

Reference (section label): [expr.new]

Link to reflector thread (if any):

Issue description:

[expr.new] p29 currently says

If the lookup finds a single matching deallocation function, that function will be called; otherwise, no deallocation function will be called.

When there're more than one potentially matching deallocation functions, some resolution are done in [temp.deduct.decl] p2 and [temp.func.order] p1.3.

However, the following cases don't seem covered:

  • one overload is a non-template function and the other is a function template specialization, and
  • both overloads are non-template static member functions of a templated class and one is more constrained than the other.

Perhaps we should apply some rules from [over.match.best.general] for selection of deallocation functions.

Currently there's implementation divergence. GCC and MSVC think a non-template deallocation function overload is better than a template specialization, while Clang doesn't (demo).

Suggested resolution:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions