The following C++ program should not compile:
struct S {
unsigned int bar : 3;
} s;
int foo(unsigned int &);
int foo(double);
int
main ()
{
return foo(s.bar); // invalid
}
According to the C++ standard, clause 13.3.3.1.4, paragraph 4, the 'bar' should
match against 'foo(unsigned int &)' because both use unsigned int, not the
alternative overload, 'foo(double)'. However, it should then fail because a
bit-field may not be bound to a reference.
GCC 4.1.1 and 4.1.2 did this correctly.
GCC 4.2.0+ silently accept it. The call is incorrectly bound to foo(double).
--
Summary: [4.2/4.3 Regression] bit-fields, references and
overloads
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: andrew dot stubbs at st dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33984