This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/40307] New: Problem with auto deducing class type inside one of its own member functions
- From: "public at alisdairm dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 May 2009 14:36:26 -0000
- Subject: [Bug c++/40307] New: Problem with auto deducing class type inside one of its own member functions
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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