<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 - type traits considered non-constant in a constrained function template in a module."
   href="https://bugs.llvm.org/show_bug.cgi?id=45249">45249</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>type traits considered non-constant in a constrained function template in a 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>C2x
          </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>When used in a `requires` clause in a module, type traits are not considered
constexpr.

test.cpp
```
export module test;

import <type_traits>;

export template<typename T>
requires(std::is_integral_v<T>)
void do_something(const T&)
{
}

```
# clang++ -std=c++20 -stdlib=libc++ -fmodules -c -Xclang -emit-module-interface
-o test.pcm test.cpp

main.cpp
```
import test;

int main() {
    do_something(7);
}
```
# clang++ -std=c++20 -stdlib=libc++ -fmodules -fimplicit-modules
-fimplicit-module-maps -fprebuilt-module-path=. main.cpp

Output:
```
In file included from main.cpp:1:
test.cpp:6:10: error: substitution into constraint expression resulted in a
non-constant expression
requires(std::is_integral_v<T>)
         ^~~~~~~~~~~~~~~~~~~~~
main.cpp:4:5: note: while checking constraint satisfaction for template
'do_something<int>' required here
    do_something(7);
    ^~~~~~~~~~~~
main.cpp:4:5: note: in instantiation of function template specialization
'do_something<int>' requested here
test.cpp:6:10: note: subexpression not valid in a constant expression
requires(std::is_integral_v<T>)
         ^
main.cpp:4:5: error: no matching function for call to 'do_something'
    do_something(7);
    ^~~~~~~~~~~~
test.cpp:7:6: note: candidate template ignored: failed template argument
deduction
void do_something(const T&)
     ^
2 errors generated.
```

# clang++ --version
clang version 11.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
70e4fb8a53984ff57b503cf13706c7e6683d650e)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin</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>