[clang] [clang] check deduction consistency when partial ordering function templates (PR #100692)

via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 30 06:41:22 PDT 2024


jeanPerier wrote:

HI @mizvekov, after your patch, some llvm build broke because a piece of code in flang does not compile anymore with tip of the tree clang:

See: https://lab.llvm.org/buildbot/#/builders/4/builds/1670

Here is a reproducer:

```
#include<complex>
std::complex<float> test(std::complex<float> z1) {
  using F0 = std::complex<float> (*)(const std::complex<float> &, const std::complex<float> &);
  F0  ptr{std::pow};
  return ptr(z1, z1);
}
```

The new error is:
```
repro.cpp:5:11: error: address of overloaded function 'pow' is ambiguous
    5 |   F0  ptr{std::pow};
      |           ^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/complex:1062:5: note: candidate function [with _Tp = float]
 1062 |     pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
      |     ^
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/complex:1899:5: note: candidate function [with _Tp = float, _Up = float]
 1899 |     pow(const std::complex<_Tp>& __x, const std::complex<_Up>& __y)
```

Other g++ (and previously clang) compile without warning here. Is this new error justified?

The piece of code with this pattern in flang is here, and is building a table of host math functions to use when folding: https://github.com/llvm/llvm-project/blob/a919588df4f108cef5829363a9ec6a1968dbb03a/flang/lib/Evaluate/intrinsics-library.cpp#L278

I have a workaround for it (#106718) but I do not understand if raising such C++ error is intentional with your patch.

https://github.com/llvm/llvm-project/pull/100692


More information about the cfe-commits mailing list