This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/85864] New: template argument string literal operator with default argument doesnt work in templates


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

            Bug ID: 85864
           Summary: template argument string literal operator with default
                    argument doesnt work in templates
           Product: gcc
           Version: 8.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dummyddd at gmail dot com
  Target Milestone: ---

The following code compiles with GCC 7.3.0 and earlier, but errors with GCC
8.1.0 and trunk.

template<class T, T... S> struct String_template {};

template<class C, C... S>
constexpr String_template<C, S...> operator""_template() {
    return String_template<C, S...> {};
}

template<class prefix = decltype("0x"_template), class T>
int hex(T v) { return 1; }

template<int v> 
void tt2() {
    auto h2 = hex<decltype("0x"_template)>(1);
    auto h = hex(2);
}

int main() {
    auto h = hex(2);
    return h;
}

<source>: In function 'void tt2()':

<source>:14:19: error: no matching function for call to 'hex(int)'

     auto h = hex(2);

                   ^

<source>:9:5: note: candidate: 'template<class prefix, class T> int hex(T)'

 int hex(T v) { return 1; }

     ^~~

<source>:9:5: note:   template argument deduction/substitution failed:

The error is only triggered by hex(2).
The error may be related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85731

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]