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++/40307] New: Problem with auto deducing class type inside one of its own member functions


The following code demonstrates the problem.  It should compile cleanly, as
demonstrated by the run_pass function, but the run_fail function generates an
error:

template< typename T >
struct test {
   test run_pass() {
      test tmp( *this );
      return tmp;
   }

   test run_fail() {
      auto tmp( *this );
      return tmp;
   }
};

int main()
{
   test<int> x;
   x.run_pass();
   x.run_fail();
   return 0;
}


Compiler output:

||=== AutoBug02, Debug ===|
In member function 'test<T> test<T>::run_fail() [with T = int]':
instantiated from here
error: 'tmp' has incomplete type
||=== Build finished: 1 errors, 0 warnings ===|


-- 
           Summary: Problem with auto deducing class type inside one of its
                    own member functions
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: public at alisdairm dot net


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40307


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