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++/79624] New: comma separate auto variables deduce different types under dependent lookup


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

            Bug ID: 79624
           Summary: comma separate auto variables deduce different types
                    under dependent lookup
           Product: gcc
           Version: 6.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rhainin1 at binghamton dot edu
  Target Milestone: ---

The following should fail to compile (does under clang) since auto is supposed
to deduce to one type.

#include <type_traits>
#include <string>

struct Cls {
  int get_int() const { return {}; }
  std::string get_string() const { return {}; }
  int i_;
  std::string s_;
};

template <typename T>
void deducer(T& t) {
  auto i = t.get_int(), s = t.get_string();  // this is invalid
  auto i2 = t.i_, s2 = t.s_;  // this is invalid
  static_assert(std::is_same<decltype(i), int>{}, "");  // passes
  static_assert(std::is_same<decltype(s), std::string>{}, "");  //passes
}  

int main() {
  Cls c;
  deducer(c);
}

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