test case

#include <iostream>

struct S
{
  signed long l: 32;
};

void foo(long)
{
  std::cout << "NG\n";
}

void foo(int)
{
  std::cout << "OK\n";
}

int main()
{
  S x = {1};
  foo(x.l+0);
  return 0;
}

result
$g++ a.c -o a; ./a
NG

According to ISO/IEC 14882 4.5 p3, type of `x.l+0' becomes int by integral
promotions. (in the case: int and long are 32 bits)
Therefore, foo(int) shall be called.
But GCC calls foo(long).
Revision of BUG 16376 seems incomplete.

GCC version: 4.2 20061212


-- 
           Summary: bit-filed: wrong overload resolution
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: s__nakayama at infoseek dot jp


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30277

Reply via email to