https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81665

Harald van Dijk <harald at gigawatt dot nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |harald at gigawatt dot nl

--- Comment #5 from Harald van Dijk <harald at gigawatt dot nl> ---
> It should work in similar way as a [Flags] attribute in C#.

Bitwise operations are allowed on enum types in C# and produce values of that
type regardless of attributes. The [Flags] attribute's effect is pretty much
limited to changing how converting enum values to strings behaves. This is not
at all what you're asking __attribute__((flags)) to do. I suggest editing the
title to not recommend mimicking C#'s attribute.

One thing that I would like to ask to consider is the debugging experience.
Please make sure that no function body is ever emitted (which implies that just
like with standard built-in operators, it's not possible to take the operator's
address). For a custom overloaded operator, it will be, and it's even possible
to break on it or step through it when debugging, but this probably isn't
useful here. Please also make sure that enough information is available to the
debugger so treat the type the same way as the compiler: in gdb, given the code

  enum E { a = 1, b = 2, c = 4 };

p b|c will produce $n = 6, whereas p (E)(b|c) will produce $n = (b | c). If the
flags attribute is added, p b|c should probably also produce $n = (b | c). This
is something you cannot and perhaps should not get with custom overloaded
operators (you can write p operator|(b,c) instead), but should be safe and
reasonable here.

Reply via email to