https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104733

            Bug ID: 104733
           Summary: [12 Regression] Likely rejects valid since
                    r12-6022-gbb2a7f80a98de3fe
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: ppalka at gcc dot gnu.org
  Target Milestone: ---

It's reduced from pythran:
https://github.com/serge-sans-paille/pythran/issues/1962

$ cat pythran.ii
template <typename _Tp> _Tp __declval(long);
template <typename _Tp> auto declval() -> decltype(__declval<_Tp>(0));
template <typename _Tp> _Tp forward;
template <class A, class B> auto mul(A a, B) -> decltype(a * 0);
namespace types {
struct str {};
} // namespace types
void operator*(types::str, long);
namespace anonymous {
template <class T> types::str str(T);
}
struct str {
  template <typename... Types>
  auto operator()(Types...) -> decltype(anonymous::str(forward<Types>...));
};
typedef decltype(mul(declval<decltype(str()(0))>(), 0)) __type10;

$ g++ pythran.ii
pythran.ii:16:21: error: no matching function for call to ‘mul(types::str,
int)’
   16 | typedef decltype(mul(declval<decltype(str()(0))>(), 0)) __type10;
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pythran.ii:4:34: note: candidate: ‘template<class A, class B> decltype ((a *
0)) mul(A, B)’
    4 | template <class A, class B> auto mul(A a, B) -> decltype(a * 0);
      |                                  ^~~
pythran.ii:4:34: note:   template argument deduction/substitution failed:
pythran.ii: In substitution of ‘template<class A, class B> decltype ((a * 0))
mul(A, B) [with A = types::str; B = int]’:
pythran.ii:16:21:   required from here
pythran.ii:4:60: error: no match for ‘operator*’ (operand types are
‘types::str’ and ‘int’)
    4 | template <class A, class B> auto mul(A a, B) -> decltype(a * 0);
      |                                                          ~~^~~
pythran.ii:16:21: error: no matching function for call to ‘mul(types::str,
int)’
   16 | typedef decltype(mul(declval<decltype(str()(0))>(), 0)) __type10;
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pythran.ii:4:34: note: candidate: ‘template<class A, class B> decltype ((a *
0)) mul(A, B)’
    4 | template <class A, class B> auto mul(A a, B) -> decltype(a * 0);
      |                                  ^~~
pythran.ii:4:34: note:   template argument deduction/substitution failed:
pythran.ii: In substitution of ‘template<class A, class B> decltype ((a * 0))
mul(A, B) [with A = types::str; B = int]’:
pythran.ii:16:21:   required from here
pythran.ii:4:60: error: no match for ‘operator*’ (operand types are
‘types::str’ and ‘int’)
    4 | template <class A, class B> auto mul(A a, B) -> decltype(a * 0);
      |                                                          ~~^~~

Reply via email to