Subject: Re: 2006Q1 audio/audacity fails to build on 3.0/amd64
To: Martin Husemann <>
From: Rhialto <>
List: pkgsrc-users
Date: 04/06/2006 01:43:30
On Thu 06 Apr 2006 at 00:54:29 +0200, Martin Husemann wrote:
> Because C++ should not require any casts from NULL to other pointer types.

Normally not perhaps, but if it disambiguates an ambiguous function
call, it may help.

> If this realy is a reference, of course this does not apply and instead the
> authors of the code should be mistreaded very badly.

No the authors don't mean to call the function with the reference
parameter. But the compiler doesn't know that.

Let's analyse the necessary conversions for both overloaded functions.
The actual parameters are

   wxChoice *item4 = new wxChoice(parent, 10001, wxDefaultPosition,
                                     wxSize(80, -1), 0, __null);

The first 4 are not in dispute: they are the same in both functions.
The problem is in 0, NULL, which should I think, behave as 0, 0.

So, matching them on 

            int n = 0, const wxString choices[] = (const wxString *) __null, 

will be no problem.

Matching them on 

            const wxArrayString& choices,
	    long style = 0,

will also work, since there is a constructor that makes an int into a

  wxArrayString(int autoSort) { Init(autoSort != 0); }

and then a reference can be taken to the temporary object[1]. Of course
this is not what the author of the code intends, but the compiler cannot
know that.

So there are two possible functions to call. To take away this
ambiguity, the NULL (0, or __null) should be make more explicit, and it
removes the second interpretation.

[1] To illustrate that g++ does consider this a valid conversion:

class Class {
    Class(int i) {};

void func(const Class &c)

main(int argc, char **argv)

    return 0;

Take away the const and g++ will complain: error: invalid initialization of non-const reference of type
'Class&' from a temporary of type 'int'

Trying out this variation:

class Class {
    Class(int i) {};

void bar(int i, char *p)

void bar(const Class &c, long l)

main(int argc, char **argv)
    bar(0, 0);
    //bar(0, __null);
    bar(0, (char *)__null);

    return 0;

it seems that g++ only complains about the middle, commented call.
Apparently it feels the need to be pedantic, despite the fact that
somebody wrote NULL which might mean to indicate the first bar()
function. I would personally have hoped for the same pedantry about the
first call. But since, on amd64 NULL is __null I do get the error, and
since on i386 it is 0, people there don't get the error.

> Martin
___ Olaf 'Rhialto' Seibert      -- You author it, and I'll reader it.
\X/ rhialto/at/        -- Cetero censeo "authored" delendum esse.