Bug 1159960

Summary: Error in boost/tr1/memory.hpp
Product: [Fedora] Fedora Reporter: Bruno A. Crespo <bruno>
Component: boostAssignee: Petr Machata <pmachata>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 20CC: dakingun, denis.arnaud_fedora, mnewsome, pertusus, pmachata
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: boost-1.54.0-10.fc20 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-11-16 14:48:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Bruno A. Crespo 2014-11-03 17:52:03 UTC
Description of problem:

Compiling this simple c++ file gives error:

#include <boost/tr1/memory.hpp>

template class boost::shared_ptr<int>;

main()

{
        }

Version-Release number of selected component (if applicable):

gcc-4.8.3-7.fc20.x86_64
boost-1.54.0-9.fc20.x86_64

How reproducible:

Always

Steps to Reproduce:
1.
cat << __EOF__ > foo.cc
#include <boost/tr1/memory.hpp>

template class boost::shared_ptr<int>;

main()

{
        }
__EOF__

2. gcc -o foo foo.cc
3.

Actual results:

g++ complains:

In file included from /usr/include/boost/shared_ptr.hpp:17:0,
                 from /usr/include/boost/tr1/memory.hpp:56,
                 from foo.cc:1:
/usr/include/boost/smart_ptr/shared_ptr.hpp: In instantiation of 'typename boost::detail::sp_array_access<T>::type boost::shared_ptr<T>::operator[](std::ptrdiff_t) const [with T = int; typename boost::detail::sp_array_access<T>::type = void; std::ptrdiff_t = long int]':
foo.cc:3:23:   required from here
/usr/include/boost/smart_ptr/shared_ptr.hpp:663:22: error: return-statement with a value, in function returning 'void' [-fpermissive]
         return px[ i ];


Expected results:

succesful compilation.

Additional info:

Comment 1 Petr Machata 2014-11-12 01:58:13 UTC
I sent an inquiry upstream, and Peter Dimov suggested this fix:

diff --git a/include/boost/smart_ptr/shared_ptr.hpp b/include/boost/smart_ptr/shared_ptr.hpp
index 82ece8b..f275f6c 100644
--- a/include/boost/smart_ptr/shared_ptr.hpp
+++ b/include/boost/smart_ptr/shared_ptr.hpp
@@ -655,7 +655,7 @@ public:
         BOOST_ASSERT( px != 0 );
         BOOST_ASSERT( i >= 0 && ( i < boost::detail::sp_extent< T >::value || boost::detail::sp_extent< T >::value == 0 ) );
 
-        return px[ i ];
+        return typename boost::detail::sp_array_access< T >::type (px[ i ]);
     }
 
     element_type * get() const BOOST_NOEXCEPT

... which works.  It does however cause a failure in one of the test cases (array_fail_array_access.cpp).  But that test just checks that subscription operator is absent or doesn't compile.  It now compiles and doesn't return any values, which might be good enough.  Maybe the test can be adapted or disregarded.  Let's see, the discussion continues.

Comment 2 Fedora Update System 2014-11-13 01:36:02 UTC
boost-1.55.0-4.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/boost-1.55.0-4.fc21

Comment 3 Fedora Update System 2014-11-13 09:43:30 UTC
boost-1.54.0-10.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/boost-1.54.0-10.fc20

Comment 4 Fedora Update System 2014-11-13 18:13:30 UTC
Package boost-1.55.0-4.fc21:
* should fix your issue,
* was pushed to the Fedora 21 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing boost-1.55.0-4.fc21'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-14893/boost-1.55.0-4.fc21
then log in and leave karma (feedback).

Comment 5 Fedora Update System 2014-11-16 14:48:07 UTC
boost-1.55.0-4.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 6 Fedora Update System 2014-11-27 08:36:18 UTC
boost-1.54.0-10.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.