This is the mail archive of the gcc-patches@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]

Re: PR c++/34758 Bad diagnostic for circular dependency in constructor default argument


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.


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