Boost logo

Boost :

Subject: Re: [boost] Failures for GCC 4.4.1 with gnu++0x
From: Christopher Schmidt (mr.chr.schmidt_at_[hidden])
Date: 2009-09-05 08:51:50


I think gcc behaves correctly.

The non-0x pair has a two-argument constructor taking const references
to T1 and T2 (20.2.2p2). Therefore the 0 you pass is directly regarded
be the null pointer constant.
The 0x pair has a 1...N argument _template_ constructor (20.2.2p6 of the
current draft). The 0 is regarded to be an int, and therefore you are
passing an actual int to initialize a pointer.

std::pair<int, int*> x(0,nullptr);
or
std::pair<int, int*> x(0,static_cast<void*>(0));

should work fine though.

-Christopher

Beman Dawes schrieb:
> On Thu, Sep 3, 2009 at 11:27 AM, Beman Dawes<bdawes_at_[hidden]> wrote:
>> Thanks to Noel Belcourt, the trunk Sandia-gcc tests show results
>> side-by-side for gcc 4.4.1 without and with C++0x features enabled.
>>
>> See http://beta.boost.org/development/tests/trunk/developer/summary.html
>>
>> Several Boost libraries are passing without 4.4.1 C++0x features but failing
>> with them:
>>
>> http://beta.boost.org/development/tests/trunk/developer/assign.html
>> ...
>>
>
> I missed iostreams. The problem seems to be a bug in gcc. This program:
>
> #include <utility>
>
> int main()
> {
> std::pair<int, int*> x(0,0);
> return 0;
> }
>
> compiles without -std=gnu++0x, but with -std=gnu++0x gets an error:
>
> c:\gcc\bin\../lib/gcc/i386-pc-mingw32/4.4.0/../../../../include/c++/4.4.0/bits/stl_pair.h:
> In constr
> uctor 'std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U1 = int, _U2 =
> int, _T1 = int, _T2 = int*]':
> cvt-0-to-ptr.cpp:5: instantiated from here
> c:\gcc\bin\../lib/gcc/i386-pc-mingw32/4.4.0/../../../../include/c++/4.4.0/bits/stl_pair.h:90:
> error:
> invalid conversion from 'int' to 'int*'
>
> I tried to find this in gcc bugzilla, but didn't come up with
> anything. Is anyone else have any knowledge of this problem?
>
> --Beman
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk