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

            Bug ID: 86703
           Summary: template auto fails deduction, where template int
                    succeeds
           Product: gcc
           Version: 7.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

Reduced example from https://stackoverflow.com/q/51561232/2069064:

struct false_type {
    static constexpr bool value = false;
};

template <AUTO> // (*) -DAUTO=auto or -DAUTO=int
struct true_type {
    static constexpr bool value = true;
};

template <class T> 
true_type<(T::value(), void(), 0)> match_auto(int);

template <class>
false_type match_auto(...);

struct pass {
    static constexpr int value() { return 1; }
};

struct fail { };

static_assert(decltype(match_auto<pass>(0))::value);
static_assert(!decltype(match_auto<fail>(0))::value);


With -DAUTO=int, this compiles. With -DAUTO=auto, the first static_assert (on
pass) triggers (on gcc 7.3, 8.1, and trunk). There shouldn't be a difference
here between int and auto. Both forms compile on clang.

Reply via email to