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

            Bug ID: 79064
           Summary: Cannot overload member function templates on type of
                    literal
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hstong at ca dot ibm.com
  Target Milestone: ---

In the case below, the signatures of the two member templates are distinct.
GCC appears to have a problem recognizing that the types of 1 and 1ll differ.
Neither Clang nor MSVC appears to have this issue.

### Source (<stdin>):
struct A {
  template <unsigned M>
  void f(char (*)[0u - 1 > (M - M) ? 42 : 47]);
  template <unsigned M>
  void f(char (*)[0u - 1ll > (M - M) ? 42 : 47]);
};

void f(A a) {
  char x[42], y[47];
  a.f<0>(&x);
  a.f<0>(&y);
}


### Compile command:
g++ -c -o a.o -x c++ -


### Actual output:
<stdin>:5:8: error: 'template<unsigned int M> void A::f(char (*)[(((0 - 1) > (M
- M)) ? 42 : 47)])' cannot be overloaded
<stdin>:3:8: error: with 'template<unsigned int M> void A::f(char (*)[(((0 - 1)
> (M - M)) ? 42 : 47)])'
<stdin>: In function 'void f(A)':
<stdin>:11:12: error: no matching function for call to 'A::f<0>(char (*)[47])'
<stdin>:3:8: note: candidate: template<unsigned int M> void A::f(char (*)[(((0
- 1) > (M - M)) ? 42 : 47)])
<stdin>:3:8: note:   template argument deduction/substitution failed:
<stdin>:11:10: note:   cannot convert '& y' (type 'char (*)[47]') to type 'char
(*)[42]'


### Expected output:
(Clean compile)


### g++ -v:
Using built-in specs.
COLLECT_GCC=/usr/local/gcc-head/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/heads/gcc/gcc-source/configure
--prefix=/usr/local/gcc-head --enable-languages=c,c++ --enable-lto
--disable-multilib --without-ppl --without-cloog-ppl --enable-checking=release
--disable-nls
Thread model: posix
gcc version 7.0.0 20161219 (experimental) (GCC)

Reply via email to