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

            Bug ID: 92446
           Summary: [10, C++20] template argument deduction fails for
                    custom non-type parameters
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dimitri.gorokhovik at free dot fr
  Target Milestone: ---

g++ (GCC) 10.0.0 20191110 (experimental)

The below snippet fails, g++ fails to deduce the type of 'i'.  The error
messages are different from those when failure is due to the custom type not
being structural. It works as expected for non-custom "old-style" NTTP (if
"BUG" is defined to 0).


/gcc-trunk/dist/bin/g++ -std=c++2a -c test-1.cpp
test-1.cpp: In function ‘int main()’:
test-1.cpp:19:18: error: no matching function for call to ‘f(qq)’
   19 |   return f (qq {});
      |                  ^
test-1.cpp:14:20: note: candidate: ‘template<p i> int f(const pp<((const
p)i)>&)’
   14 | template <p i> int f (pp <i> const &);
      |                    ^
test-1.cpp:14:20: note:   template argument deduction/substitution failed:
test-1.cpp:19:18: note:   couldn’t deduce template parameter ‘i’
   19 |   return f (qq {});
      |                  ^


#define BUG 1

#if BUG
struct p { unsigned p_ {}; };
#else
using p = unsigned;
#endif

template <p i> struct pp {};
struct qq : public pp <p {}> {};

template <p i> int f (pp <i> const &);


int main ()
{
  return f (qq {});
};

Reply via email to