On Sat, Jun 20, 2015 at 03:02:06AM +0300, Mikhail Maltsev wrote: > - /* We do not warn for constants because they are typical of macro > - expansions that test for features. */ > - if (CONSTANT_CLASS_P (op_left) || CONSTANT_CLASS_P (op_right)) > + /* We do not warn for literal constants because they are typical of macro > + expansions that test for features. Likewise, we do not warn for > + const-qualified and constexpr variables which are initialized by > constant > + expressions, because they can come from e.g. <type_traits> or similar > user > + code. */ > + if (TREE_CONSTANT (op_left) || TREE_CONSTANT (op_right)) > return;
That looks wrong, because with TREE_CONSTANT we'd warn in C but not in C++ for the following: const int a = 4; void f (void) { const int b = 4; static const int c = 5; if (a && a) {} if (b && b) {} if (c && c) {} } Note that const-qualified types are checked using TYPE_READONLY. But I'm not even sure that the warning in the original testcase in the PR is bogus; you won't get any warning when using e.g. foo<unsigned, signed>(); in main(). Marek