Skip to content

Aliases and uniqueness of lambda in default argument of a class template parameter #123414

@cor3ntin

Description

@cor3ntin

Consider

template<typename T, typename F = decltype([](){} )>
struct Type {};

template<typename A>
using C = Type<A>;

static_assert(std::same_as<Type<int>,Type<int>>); // #1
static_assert(std::same_as<C<int>,C<int>>); // #2

https://godbolt.org/z/6ofdP1bPz

All compilers reject #1. Only clang rejects #2.

This seems vaguely related, but distinct from CWG2794

Given https://eel.is/c++draft/temp.alias#2

When a template-id refers to the specialization of an alias template, it is equivalent to the associated type obtained by substitution of its template-arguments for the template-parameters in the defining-type-id of the alias template.

And https://eel.is/c++draft/temp#arg.general-9.sentence-1

When a simple-template-id does not name a function, a default template-argument is implicitly instantiated when the value of that default argument is needed.

It's clear as mud (to me) what the expected behavior should be.
CWG discussion https://lists.isocpp.org/core/2025/01/16895.php

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"diverges-from:edgDoes the clang frontend diverge from edg compiler on this issuediverges-from:gccDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions