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: Richard Guenther <richard dot guenther at gmail dot com>
- To: Daniel Marjamäki <daniel dot marjamaki at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 29 Jul 2011 13:25:55 +0200
- 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.
Ok, I think the idea of the patch sounds reasonable then (but maybe
we can do even better for more cases by adjusting the
+ if (TREE_CODE(tree_value) != INTEGER_CST)
check to, say, if (! TREE_CONSTANT (tree_value)) which at least
would also cover floating-point constants and strings. Eventually
C++0x offers some more useful predicate give its constexpr feature.
I suppose C++ maintainers will have to have a look here anyway.
And I guess the example in the manual should be adjusted as Jakub
> Best regards,