Skip to content

Unexpected behavior in deduction of nested templates with template template parameters (inconsistent with GCC, MSVC) #81577

Open
@13steinj

Description

@13steinj

I don't have enough practice with standard-ese to express myself any better than that, unfortunately. Define EVEN_WORSE or ALTERNATIVE_EVEN_WORSE for a different, but seemingly related, inconsistency. Define FIXED to fix the original issue, and "fix" the "even worse" inconsistencies (successful compile, unexpectedly).

I'm happy to provide the motivating example, it's just larger. A whole load of transitional layers from one set of types to another.

Reduced Example
template<typename>
struct Wrapper;

template<template<typename> typename, typename T>
using ComposedWrapper = Wrapper<T>;

template<typename...>
struct mp_list;

template<typename>
struct converter_impl;

template<typename T>
using converter = converter_impl<T>::type;

template<
#if !defined(EVEN_WORSE)
    template<typename> typename Wrapper,
#endif
    typename T
>
struct converter_impl<mp_list<Wrapper<T>>> {
    using type = void;
};

template<typename T>
struct converter_impl<ComposedWrapper<Wrapper, T>> {
    using type = converter<T>;
};

#if defined(__clang__) && defined(FIXED)

template<typename T>
struct converter_impl<ComposedWrapper<Wrapper, mp_list<T>>> {
    using type = int;
};

#endif

template<typename>
concept valid = true;

static_assert(valid<converter<ComposedWrapper<Wrapper,
#if !defined(ALTERNATIVE_EVEN_WORSE)
    mp_list<
#endif
        mp_list<int>
#if !defined(ALTERNATIVE_EVEN_WORSE)
    >
#endif
>>>);

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions