TITLE: Ambiguous conversions PROBLEM: bs@alice.att.com (Bjarne Stroustrup), 27 Mar 93 To try to summarize the problem, given void f(long); void f(char*); what should be done for void g() { f(0); } RESPONSE: kanze@us-es.sel.de (James Kanze @ SEL) As I read the ARM, in the above case, s & 0 *should* call the char* operator, no matter how unintuitive this seems, since 0 (NULL pointer) is an exact match for char*, whereas a conversion (admittedly trivial) is required to convert the int 0 to a long. What compilers actually do seems to vary. Cfront (or at least Sun CC) treats it as an ambiguity, and generates an error. GNU seems to pick one at random. In the meantime, try explicit casts, or 0L to get the long version. PROBLEM: bs@alice.att.com (Bjarne Stroustrup) AT&T Bell Laboratories, Murray Hill NJ The answer is that the call is ambiguous. 0 is an int and there is no rule in C++ to brefer the int->longconversion over the int->char* conversion or visa versa. See sec13.2 of the reference manual in either the ARM or ``The C++ Programming Language (2nd edition). Nits: 0->long and 0->char* are both standard conversions (not ``trivial'') conversions in the technical sense of that term). The type of 0 is int.