This is the mail archive of the gcc-help@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: -Wenum-compare and template metaprogramming


On 2017-05-04 23:33 +0100, Jonathan Wakely wrote:
> On 4 May 2017 at 16:39, Martin Sebor <msebor@gmail.com> wrote:
> > Assuming the code defines the enums as unnamed types, comparing
> > their enumerators seems unlikely to be a problem.  Or can you
> > think of some accidental misuse that the warning would detect?
> 
> I can't immediately think of any problem, except for encouraging the
> hack, which I'm not fond of :-)

But in C++03 we don't have constexpr and have to use hack...

> > If there isn't one it might to detect the (legacy) idiom and
> > suppress the warning in that case.  Or add a warning suboption
> > to control it, until the code transitions to the more modern
> > way of doing things.  Or perhaps only warn in C++ 11 mode and
> > later.

Maybe we should add something like "-Wenum-hack", and give a hint
to use constexpr for C++11/14/17.
-- 
Xi Ruoyao <ryxi@stu.xidian.edu.cn>
School of Aerospace Science and Technology, Xidian University


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