-Wenum-compare and template metaprogramming
Xi Ruoyao
ryxi@stu.xidian.edu.cn
Fri May 5 03:54:00 GMT 2017
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
More information about the Gcc-help
mailing list