Boost logo

Boost :

Subject: Re: [boost] [smart_ptr] extra colon on make_shared variadic template instantiation
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-09-19 13:44:29


Le 19/09/13 09:53, Peter Dimov a écrit :
> Vicente J. Botet Escriba wrote:
>> Hi,
>>
>> while instantiating this template, the Intel compiler finds that
>> there is an extra colon when Args is empty.
>>
>>
>> ::new( pv ) T( boost::detail::sp_forward<Arg1>( arg1 ),
>> boost::detail::sp_forward<Args>( args )... );
>> ^
>> Is this a bug on the compiler or on Boost.SmartPtr?
>
> I have no idea where an extra colon could come from, but maybe you
> mean an extra comma. This should be a compiler bug.
Yes, an extra comma.
Maybe it is an extra bug, but it is worth providing a workaround.
>
>> Hi,
>>
>> could I commit this patch
> ...
>> +template< class T, class... Args > typename
>> boost::detail::sp_if_not_array< T >::type make_shared( Args && ...
>> args )
>
> I'm not sure how this could help. This overload is either ambiguous
> with the Arg1&& one, or less specialized. Do the make_shared tests
> pass on all compilers after the patch?
>
> The reason that there are two overloads, one without arguments, the
> other with Arg1&& and Args&&..., is that earlier versions of g++
> treated new T(args...) as new T when args... is empty, instead of the
> correct new T(). There is a test that checks for this bug. If the
> current crop of supported compilers no longer suffers from it, the two
> overloads can be replaced by the simple variadic Args... version. But
> adding the Args... version in addition to the other two makes no sense
> to me.
>
>

I recognize that it should be a better solution.

I have compiled with gcc-4.5 and newer, clang-3.1+3.2 and Intel 12.1.3

Not tested with MSVC :(

Best,
Vicente


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