This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C/C++ PATCH] Add -Wlogical-not-parentheses (PR c/49706)


On 06/02/2014 01:04 PM, Marek Polacek wrote:
#ifdef __cplusplus
template <class T, class U> bool f(T t, U u) { return (!t == u); }
#endif

I think !t should have null TREE_TYPE in this case.

Hmm, I see no crash; the types seem to be
template_type_parm 0x7ffff013d5e8 T type_0 type_6 VOID ...

Right, because you're pulling out the operand of the not. OK, then you need something a little more complicated like !g(t).

Do we actually want to warn in that case?  As the patch doesn't warn
if the type is bool or vector, if somebody instantiates the above with
say T=bool, U=bool, then we'd warn on something that otherwise will not be
warned about when not in template.

I think we still want to warn. A template that is only correct for one possible template argument shouldn't be a template.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]