This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/77592] gcc accepts delegated constructor with circular reference
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 14 Sep 2016 15:19:55 +0000
- Subject: [Bug c++/77592] gcc accepts delegated constructor with circular reference
- Auto-submitted: auto-generated
- References: <bug-77592-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77592
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Gawain Bolton from comment #0)
> Compilation segfaults using gcc v5.3, v6.1 and gcc HEAD 7.0.0 20160913
Compilation works fine, the executable segfaults, due to a stack overflow.
The standard says your code is "ill-formed, no diagnostic required" so
compilers aren't required to reject the code, but it would be nice to diagnose
it.
Clang does:
circ.cc:10:7: error: constructor for 'T' creates a delegation cycle
[-Wdelegating-ctor-cycles]
: T(i,s)
^
circ.cc:3:5: note: it delegates to
T(const int i,
^
circ.cc:8:5: note: which delegates to
T(const char * s,
^
And EDG does:
"circ.cc", line 10: error: constructor delegates directly or indirectly to
itself
: T(i,s)
^