This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR c++/34758 Bad diagnostic for circular dependency in constructor default argument
- From: "Manuel López-Ibáñez" <lopezibanez at gmail dot com>
- To: "Paolo Carlini" <paolo dot carlini at oracle dot com>
- Cc: "Gcc Patch List" <gcc-patches at gcc dot gnu dot org>, "Mark Mitchell" <mark at codesourcery dot com>, "Wolfgang Bangerth" <bangerth at dealii dot org>, reichelt at gcc dot gnu dot org, "Ismail Dönmez" <ismail at pardus dot org dot tr>, fang at csl dot cornell dot edu, "Richard Guenther" <richard dot guenther at gmail dot com>
- Date: Mon, 18 Aug 2008 22:43:05 +0200
- Subject: Re: PR c++/34758 Bad diagnostic for circular dependency in constructor default argument
- References: <6c33472e0808181208o7fdfe97ao3e8b089e17c90c54@mail.gmail.com> <48A9CA7B.3080003@oracle.com>
2008/8/18 Paolo Carlini <paolo.carlini@oracle.com>:
> Hi Manuel,
>>
>> Bootstrapped and regression tested on x86_64-unknown-linux-gnu with
>> --enable-languages=all,ada
>>
>> OK for trunk?
>>
>
> at some point I tried working on this issue and it turned out that, among
> other things, maybe "circular dependency" wasn't a clear way to explain the
> problem:
>
> http://gcc.gnu.org/ml/gcc-patches/2008-01/msg00799.html
I see. First, I agree that checking for parmnum == 0 allows for nicer messages.
Second, in the current testcase:
+ A (const A& = A()); // { dg-error "error: circular dependency in
default argument for parameter 1 of " }
There *is* a circular dependency, isn't there?
The problem is the "circular dependency" wording does not apply to other cases:
struct S {
S(const S& = f());
static const S& f(int i = 3);
};
If we can differentiate between both cases, then we could say something like
"error: parameter 1 in declaration of S(const S&) calls f(), which has
not been declared yet, with default arguments"
or perhaps even simpler:
"error: f() needs to be declared before being called with default arguments"
Opinions? Hints on how to differentiate between both cases?
Cheers,
Manuel.