https://bugs.llvm.org/show_bug.cgi?id=45292
Bug ID: 45292
Summary: Class template argument deduction (CTAD) not working
in module
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++2a
Assignee: unassignedclangb...@nondot.org
Reporter: rb...@eudoxos.de
CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk
Given the following module
// ----------------------------------
export module mod;
export template<typename T>
struct something
{
constexpr something(T){}
};
export template<typename T>
constexpr auto make_something(T t)
{
return something{t}; // uses CTAD
}
// ----------------------------------
Compiled with clang: clang++ -std=c++20 -stdlib=libc++ -fmodules -c -Xclang
-emit-module-interface -o mod.pcm mod.cpp
And the following application code:
// ----------------------------------
import mod;
int main()
{
constexpr auto x = make_something(7);
}
// ----------------------------------
Compiled with: clang++ -std=c++20 -stdlib=libc++ -fmodules -fimplicit-modules
-fimplicit-module-maps -fprebuilt-module-path=. main.cpp
The latter fails with the following error message:
// ----------------------------------
In file included from main.cpp:1:
mod.cpp:13:12: error: no viable constructor or deduction guide for deduction of
template arguments of 'something'
return something{t}; // uses CTAD
^
main.cpp:5:28: note: in instantiation of function template specialization
'make_something<int>' requested here
constexpr auto x = make_something(7);
^
1 error generated.
// ----------------------------------
Of course, I can change the module code and specify the the template parameter.
But this seems to be a bug, see also discussion here:
https://stackoverflow.com/questions/60827958/should-class-template-argument-deduction-ctad-work-inside-modules
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs