This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/30277] bit-field: wrong overload resolution
- From: "tom at honermann dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 25 Jul 2016 17:10:50 +0000
- Subject: [Bug c++/30277] bit-field: wrong overload resolution
- Auto-submitted: auto-generated
- References: <bug-30277-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30277
--- Comment #4 from Tom Honermann <tom at honermann dot net> ---
We recently got bit by this. It is still an issue in latest gcc trunk:
$ cat t.cpp
enum E : int {
e1 = 1
};
constexpr E operator-(E, E) {
return (E)99;
}
typedef struct {
E e;
E ebf : 16;
} S;
constexpr S s = { e1, e1 };
static_assert(99 == (int)(s.e-s.e),"Overload resolution failed for
non-bit-field");
static_assert(99 == (int)(s.ebf-s.ebf),"Overload resolution failed for
bit-field");
$ g++ --version
g++ (GCC) 7.0.0 20160721 (experimental)
...
$ g++ -c -std=c++11 t.cpp
t.cpp:9:14: warning: â<anonymous struct>::ebfâ is too small to hold all values
of âenum Eâ
E ebf : 16;
^~
t.cpp:13:1: error: static assertion failed: Overload resolution failed for
bit-field
static_assert(99 == (int)(s.ebf-s.ebf),"Overload resolution failed for
bit-field");
^~~~~~~~~~~~~
(I would love to be able to disable that warning as well: bug 51242)