This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/79624] New: comma separate auto variables deduce different types under dependent lookup
- From: "rhainin1 at binghamton dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 20 Feb 2017 07:48:27 +0000
- Subject: [Bug c++/79624] New: comma separate auto variables deduce different types under dependent lookup
- Auto-submitted: auto-generated
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);
}