This is the mail archive of the
mailing list for the GCC project.
Re: a warning to implement
Richard Sandiford wrote:
>Gabriel Dos Reis <firstname.lastname@example.org> writes:
>>Richard Sandiford <email@example.com> writes:
>>| Gabriel Dos Reis <firstname.lastname@example.org> writes:
>>| > I'm not sure I can represent on this public list, opinions expressed
>>| > on closed mailing-lists. However, you might want to consult
>>| > c++std-core archive. You'll discover people have use of
>>| > self-initialisation even if you cannot imagine such use.
>>| But if gcc doesn't behave the way these people expect, that sounds
>>| like an even better reason to warn as part of -Wall.
>>Then T is a user defined type,
>> T x = x;
>>should be implemented correctly by GCC.
>>| If gcc
>>| implements the intended behaviour at some point in the future,
>>| we could stop -Wself-initialization or whatever from warning
>>| about those cases.
>>Now you'll have to argue why you're stopping something documented used
>>to work as documented.
>My suggestion was to warn only about cases when we can detect the
>behaviour is not documented or well-defined. The option itself could be
>documented that way. If the behaviour of more self-initializers becomes
>defined over time, the number of cases we warn about would go down.
>>From that point of view, the warning wouldn't trigger for:
> T x = x;
>in the well-defined cases you're talking about, but would, for example,
>when T==int (which was the example that the original poster gave). If
>the warning worked that way, would it be OK for -Wall?
Probably a dumb question, but shouldn't this error be noticed in the
same way that code like
b = a;
would be? Shouldn't you already be seeing a 'used before initialized'