This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/51424] New: [C++11] G++ should diagnose self-delegating constructors
- From: "jason at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 05 Dec 2011 16:09:39 +0000
- Subject: [Bug c++/51424] New: [C++11] G++ should diagnose self-delegating constructors
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51424
Bug #: 51424
Summary: [C++11] G++ should diagnose self-delegating
constructors
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jason@gcc.gnu.org
CC: pedro.lamarao@gmail.com, ville.voutilainen@gmail.com
This modification of g++.dg/template/meminit1.C should get a diagnostic in
C++11 mode as well:
template <class T >
struct S
{
S() : S() {} // { dg-message "delegating constructors" "" { target c++98 } }
// { dg-error "delegates to itself" "" { target c++11 } }
};
S<int> s;
because 12.6.2 says,
"If a constructor delegates to itself directly or indirectly, the program is
ill-formed; no diagnostic is required."
The diagnostic is not required, but it is easy to give, so we should do so.