Issue 202318
Summary C++23: template function parameter instantiation in none-invoked function
Labels new issue
Assignees
Reporter anders-wind
    ```
#include <concepts>
#include <random>

template<std::floating_point T>
constexpr auto foo(std::uniform_real_distribution<T> x) {
}

template<std::integral T>
constexpr auto foo(std::uniform_int_distribution<T> c) {
}

auto main() -> int {
    foo<int>({});
}
```
Expected behavior is that it compiles successfully with clang-22 and flags `-std=c++23 -stdlib=libc++`.
However it fails with:
```
/cefs/26/26ccf7a2fd1f9d4667de2307_consolidated/compilers_c++_clang_22.1.0/bin/../include/c++/v1/__random/uniform_real_distribution.h:29:17: error: static assertion failed due to requirement 'std::__libcpp_random_is_valid_realtype<int>::value': RealType must be a supported floating-point type
   29 | static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:14:14: note: in instantiation of template class 'std::uniform_real_distribution<int>' requested here
   14 |     foo<int>({});
      | ^
<source>:14:5: note: while substituting deduced template arguments into function template 'foo' [with T = int]
   14 |     foo<int>({});
      | ^
```

It also fails when using gcc's stdlib. 
https://godbolt.org/z/b6ccGPcj5 : notice that it compiles successfully with gcc and msvc
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to