[Bug c++/43663] Can't take a const-ref to a bit field
james.dennett at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun May 15 12:54:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43663
--- Comment #8 from James Dennett <james.dennett at gmail dot com> 2011-05-15 12:34:51 UTC ---
Interestingly this works with Apple's g++ 4.2.1, specifically
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3), but
not with their 4.0.1 release.
Tested with:
int main() {
struct S {
S(): i(0) {}
int i : 3;
};
S s;
printf("&s: %p\n", (void*)&s);
int const& cr(s.i); // should compile, binding to a temporary
printf("&cr: %p\n", (void*)&cr);
}
A non-const reference still correctly gives an error:
st.cc:12: error: invalid initialization of reference of type ‘int&’ from
expression of type ‘signed char:3’
More information about the Gcc-bugs
mailing list