size_t overloading ambiguity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux