size_t overloading ambiguity

corey taylor corey.taylor@gmail.com
Wed Feb 23 20:20:00 GMT 2005


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



More information about the Gcc-help mailing list