This is the mail archive of the
mailing list for the GCC project.
Re: Re: patch: don't issue -Wreorder warnings when order doesn't matter
- From: Peter Bigot <bigotp at acm dot org>
- To: Daniel Marjamäki <daniel dot marjamaki at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 30 Jul 2011 17:55:12 -0500
- Subject: Re: Re: patch: don't issue -Wreorder warnings when order doesn't matter
- References: <CAMabPZQaTVbe8qEosVDp9yJz=74StcmpQaXh5PquyGq8iwH3tw@mail.gmail.com>
2011/7/29 Daniel Marjamäki <email@example.com>:
>> Why doesn't it matter in this case but it matters when the initializer
>> are non-constant?
> It doesn't matter because the program will behave the same no matter
> if the initializations are reordered or not. Logically it will behave
> just as the user expects no matter if he expects reordering or not.
> When one initializer is non-constant there might be a dependency
> between the two initializations and the wrong order might be a bug.
> I would like to silence such warnings also, but I don't want to try to
> determine if there is dependencies or not.
>> If you don't want to fix up your code, just compile it with -Wno-reorder.
> I don't want to use -Wno-reorder , because then I won't see the real
> problems. Don't get me wrong, I like this check.
> When gcc generates noise I think it is better to fix gcc than to fix my code.
> The only reason I can think of to keep this noise is for purely
> stylistic reasons. Somebody might think it is a stylistic problem to
> initialize members backwards. But then -Wreorder should also warn
> about common assignments and I doubt anybody wants that.
If the initializer is constant, but the member value that's being
initialized has a
non-trivial constructor with a side effect, your patch will inhibit the warning
but the program will not behave the same as if reordering had not happened.