Opened 10 years ago
Closed 10 years ago
#6943 closed Bugs (invalid)
gcc 4.7 issue in combination with intrusive_ptr_add_ref and intrusive_ptr_release (boost_1_49_0/boost/intrusive_ptr.hpp - boost_1_49_0/boost/smart_ptr/intrusive_ptr.hpp )
Reported by: | Owned by: | Peter Dimov | |
---|---|---|---|
Milestone: | Boost 1.49.0 | Component: | smart_ptr |
Version: | Boost 1.49.0 | Severity: | Regression |
Keywords: | Cc: |
Description
The code of scummvm-tools ( http://www.scummvm.org/downloads/#tools ) has been build accoring to this example. http://www.codeproject.com/Articles/8394/Smart-Pointers-to-boost-your-code#intrusive_ptr%20-%20lightweight%20shared%20pointer
<fails with> g++ -MMD -MF "decompiler/.deps/disassembler.d" -MQ "decompiler/disassembler.o" -MP -Wall -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -g -ansi -W -Wno-unused-parameter -Wno-empty-body -Wno-long-long -Wno-multichar -Wno-unknown-pragmas -Wno-reor der -Wpointer-arith -Wcast-qual -Wshadow -Wnon-virtual-dtor -Wwrite-strings -fcheck-new -DHAVE_CONFIG_H -DPOSIX -I. -I. -c decompiler/disassembler.cpp -o decompiler/disassembler.o In file included from decompiler/instruction.h:30:0,
from decompiler/disassembler.h:29, from decompiler/disassembler.cpp:23:
/usr/include/boost/smart_ptr/intrusive_ptr.hpp: In instantiation of 'boost::intrusive_ptr<T>::intrusive_ptr(const boost::intrusive_ptr<T>&) [with T = Value; boost::intrusive_ptr<T> = boost::intrusive_ptr<Value>]': decompiler/value.h:335:90: required from here /usr/include/boost/smart_ptr/intrusive_ptr.hpp:91:23: error: 'intrusive_ptr_add_ref' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] In file included from decompiler/instruction.h:33:0,
from decompiler/disassembler.h:29, from decompiler/disassembler.cpp:23:
decompiler/refcounted.h:52:13: note: 'void boost::intrusive_ptr_add_ref(RefCounted*)' declared here, later in the translation unit In file included from decompiler/instruction.h:30:0,
from decompiler/disassembler.h:29, from decompiler/disassembler.cpp:23:
/usr/include/boost/smart_ptr/intrusive_ptr.hpp: In instantiation of 'boost::intrusive_ptr<T>::~intrusive_ptr() [with T = Value]': decompiler/value.h:335:90: required from here /usr/include/boost/smart_ptr/intrusive_ptr.hpp:96:23: error: 'intrusive_ptr_release' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] In file included from decompiler/instruction.h:33:0,
from decompiler/disassembler.h:29, from decompiler/disassembler.cpp:23:
decompiler/refcounted.h:59:13: note: 'void boost::intrusive_ptr_release(RefCounted*)' declared here, later in the translation unit make: * [decompiler/disassembler.o] Error 1 </fails with> https://build.opensuse.org/package/live_build_log?arch=i586&package=scummvm-tools&project=games&repository=openSUSE_Factory
It was OK until gcc 4.7. As gcc 4.7 is much more strict the build of the code doesn't work any more.
I suspect boost itself as no (active) functions void intrusive_ptr_add_ref(T * p); void intrusive_ptr_release(T * p); In boost_1_49_0/boost/smart_ptr/intrusive_ptr.hpp
Searching the internet shows that more programs have this issue. It's not unique for scummvm-tools, they solved it, for the time being, with "-fpermissive" which IMHO isn't the correct way. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672033 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672397
Attachments (1)
Change History (7)
comment:1 by , 10 years ago
comment:3 by , 10 years ago
Component: | intrusive → smart_ptr |
---|---|
Owner: | changed from | to
Changing componente as intrusive_ptr belongs to smart_ptr. I don't think it's a bug, the standard requires a previous declaration. You should include boost/intrusive_ptr.hpp before calling boost::intrusive_ptr_add_ref.
comment:4 by , 10 years ago
You should define intrusive_ptr_add_ref and intrusive_ptr_release in the namespace of the class, not in namespace boost.
comment:5 by , 10 years ago
This can be closed (that article contains bad information.)
Thanks for clearing that up.
comment:6 by , 10 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
I had the same error/issue. My code had the form:
My solution was to change:
to
It this was slightly unexpected for me.
It compiled without the change on gcc 4.5.3 but would not on clang 3.1 and gcc 4.7.0
Not sure if it is a bug (would like clarification.)