Skip to content

[BUG] Can't pass dependent type template argument #727

Open
@JohelEGP

Description

@JohelEGP

Title: Can't pass dependent type template argument.

Minimal reproducer (https://cpp2.godbolt.org/z/W1dKeeKso):

f: <T> () std::vector<T::value_type>();
main: () = { }
Commands:
cppfront main.cpp2
clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cpp

Expected result: std::vector<typename T::value_type>.

Actual result and error: std::vector<T::value_type>.

Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"



//=== Cpp2 type definitions and function declarations ===========================

template<typename T> [[nodiscard]] auto f() -> auto;
auto main() -> int;


//=== Cpp2 function definitions =================================================

template<typename T> [[nodiscard]] auto f() -> auto { return std::vector<T::value_type>();  }
auto main() -> int{}
Output:
build/main.cpp:18:74: error: template argument for template type parameter must be a type; did you forget 'typename'?
   18 | template<typename T> [[nodiscard]] auto f() -> auto { return std::vector<T::value_type>();  }
      |                                                                          ^
      |                                                                          typename 
/opt/compiler-explorer/clang-trunk-20231004/bin/../include/c++/v1/__iterator/wrap_iter.h:102:21: note: template parameter is declared here
  102 |     template <class _Tp, class _Alloc> friend class _LIBCPP_TEMPLATE_VIS vector;
      |                     ^
1 error generated.

See also:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions