This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

size_t overloading ambiguity


Hello all, 

  This issue was reported by our OSX tester/developer using GCC.  I
cannot produce the results under linux gcc 3.3 or so.

  The problem *appears* to be that unsigned int and long unsigned int
and other typedefs with these values are implicitly converting or
something instead of properly matching the overload of unsigned int.

  The code below will create an overload ambiguity with the OSX gcc. 
The same happens for size_t.

#include <stdio.h>
#include <stddef.h>

void foo (int x)
{
    printf("Foo of int");
}

void foo (unsigned int x)
{
    printf("Foo of unsigned int");
}

int main (int argc, char* argv[])
{
    printf("sizeof(unsigned int): %d\n", sizeof(unsigned int));
    printf("sizeof(size_t): %d\n", sizeof(size_t));
    printf("sizeof(long unsigned int): %d\n", sizeof(long unsigned
int));

    long unsigned int a = 1;
    foo(a);
}

corey


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]