<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Class template argument deduction (CTAD) not working in module"
   href="https://bugs.llvm.org/show_bug.cgi?id=45292">45292</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Class template argument deduction (CTAD) not working in module
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++2a
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>rbock@eudoxos.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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: 
<a href="https://stackoverflow.com/questions/60827958/should-class-template-argument-deduction-ctad-work-inside-modules">https://stackoverflow.com/questions/60827958/should-class-template-argument-deduction-ctad-work-inside-modules</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>