2011/7/29 Daniel Marjamäki <daniel.marjam...@gmail.com>: > Hello! > >> 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 says. Thanks, Richard. > Best regards, > Daniel >