[Bug c++/69436] Method returning "auto&" fails to resolve "*this" (-std=c++17)

2016-01-27 Thread vmorgulys at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69436

--- Comment #6 from vmorgulys at gmail dot com ---
Hello Jonathan,

I have another similar issue with auto and deleted contructrors
("=delete"). They are not detected at compile time.

Do you think it is related to what you mention in your comment (Concept TS)?

If I understand correctly, I need to build gcc with the trunk version to be
sure. Is it correct?

Thank you a lot for your work on gcc.

Cheers,

Marc

2016-01-22 22:03 GMT+01:00 redi at gcc dot gnu.org <gcc-bugzi...@gcc.gnu.org
>:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69436
>
> --- Comment #2 from Jonathan Wakely  ---
> (In reply to vmorgulys from comment #0)
> >  auto& f2(auto v)
>
> This is not standard C++, it's part of the Concepts TS, and so doesn't work
> properly until GCC 6.
>
> --
> You are receiving this mail because:
> You reported the bug.
>

[Bug c++/69436] New: Method returning "auto&" fails to resolve "*this" (-sdt=c++17)

2016-01-22 Thread vmorgulys at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69436

Bug ID: 69436
   Summary: Method returning "auto&" fails to resolve "*this"
(-sdt=c++17)
   Product: gcc
   Version: 5.3.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vmorgulys at gmail dot com
  Target Milestone: ---

Hello everybody,

Here is a test case.

//bad auto

class c1
{
 public:

 auto& f1()
 {
  return *this;
 }

 auto& f2(auto v)
 {
  return *this;
 }
};

int main(int count,const char** arguments)
{
 c1 a;

 a.f1(); //ok
 a.f2(42); //failed

 return 0;
}

Compiled with:

g++ -O3 -g -std=c++17 -fmax-errors=8 -Wall -Wno-strict-overflow

The error message is:

source/main.cpp: In instantiation of ‘auto& c1::f2(auto:1) [with auto:1 =
int]’:
source/main.cpp:23:9:   required from here
source/main.cpp:14:11: error: invalid initialization of reference of type
‘int&’ from expression of type ‘c1’
   return *this;

I'm not sure if it's a bug or not. It seems related to:

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

Let me know if I'm wrong.

Cheers.