[stlport-bugs] [ stlport-Bugs-1799048 ] Container pointer specialization feature fails to compile
Brought to you by:
complement
From: SourceForge.net <no...@so...> - 2007-09-29 10:15:00
|
Bugs item #1799048, was opened at 2007-09-20 22:47 Message generated for change (Comment added) made by andysem You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=766244&aid=1799048&group_id=146814 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General code Group: 5.1 >Status: Open Resolution: None Priority: 5 Private: No Submitted By: Andrey Semashev (andysem) Assigned to: Francois Dumont (dums) Summary: Container pointer specialization feature fails to compile Initial Comment: Hi. The following problem is indicated in both 5.1.3 and 5.1 HEAD of the repository. When the pointer specialization optimization for containers is turned on (_STLP_USE_PTR_SPECIALIZATIONS defined) the code like this does not compile: #include <vector> struct A { std::vector< A > m_vec; }; The output is: lastique@linux-lastique:~> c++ -v Using built-in specs. Target: x86_64-suse-linux Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.1.2 --enable-ssp --disable-libssp --disable-libgcj --with-slibdir=/lib64 --with-system-zlib --enable-shared --enable-__cxa_atexit --enable-libstdcxx-allocator=new --program-suffix=-4.1 --enable-version-specific-runtime-libs --without-system-libunwind --with-cpu=generic --host=x86_64-suse-linux Thread model: posix gcc version 4.1.2 20061115 (prerelease) (SUSE Linux) lastique@linux-lastique:~> c++ -I ./STLPort/stlport -L ./STLPort/lib -lstlport_gcc 1.cpp ./STLPort/stlport/stl/pointers/_tools.h: In instantiation of ‘stlp_priv::_StorageType<A>’: ./STLPort/stlport/stl/pointers/_vector.h:53: instantiated from ‘stlp_std::vector<A, stlp_std::allocator<A> >’ 1.cpp:5: instantiated from here ./STLPort/stlport/stl/pointers/_tools.h:79: error: invalid use of undefined type ‘struct A’ 1.cpp:4: error: forward declaration of ‘struct A’ ./STLPort/stlport/stl/pointers/_tools.h:80: error: invalid use of undefined type ‘struct A’ 1.cpp:4: error: forward declaration of ‘struct A’ ./STLPort/stlport/stl/pointers/_tools.h:81: error: invalid use of undefined type ‘struct A’ 1.cpp:4: error: forward declaration of ‘struct A’ ./STLPort/stlport/stl/pointers/_tools.h:82: error: invalid use of undefined type ‘struct A’ 1.cpp:4: error: forward declaration of ‘struct A’ The problem is that A is not defined at the point of the vector instantiation, but the latter (_StorageType, to be more specific) uses it in the context that requires it to be defined (a function call with a temporary of type A as an argument in the sizeof expression). I have a solution for compilers with partial template specialization support (see patch attached), that was sufficient for me. But I haven't thought much of the solution for deficient compilers. ---------------------------------------------------------------------- >Comment By: Andrey Semashev (andysem) Date: 2007-09-29 14:14 Message: Logged In: YES user_id=1819621 Originator: YES The original test example works for me. Will there be a unit test? ---------------------------------------------------------------------- Comment By: Francois Dumont (dums) Date: 2007-09-29 00:13 Message: Logged In: YES user_id=1096600 Originator: NO As promise, I have done a fix in trunk, you are welcome to test it. I haven't use your patch as using __type_traits might also require one day type to be completely defined with compilers having intrinsic type traits support. ---------------------------------------------------------------------- Comment By: Ulrich Eckhardt (eckhardt) Date: 2007-09-21 16:18 Message: Logged In: YES user_id=1522877 Originator: NO The reason for why not in the 5.1.x release is simple, we want to push out a new release really soon now(tm), and the patch you suggest would add a new feature that would require testing things over again. BTW: instantiating vector (or pretty much anything from the C++ stdlib) on an incomplete type is undefined behaviour. That means that firstly it is not really a bug in STLport and secondly it means that your code becomes non-portable if you use it. I just wanted to point out this fact for the record and to avoid misunderstandings. cheers Uli ---------------------------------------------------------------------- Comment By: Andrey Semashev (andysem) Date: 2007-09-21 11:28 Message: Logged In: YES user_id=1819621 Originator: YES Why not 5.1 branch? The patch is for 5.1 anyway. ---------------------------------------------------------------------- Comment By: Francois Dumont (dums) Date: 2007-09-20 23:31 Message: Logged In: YES user_id=1096600 Originator: NO Thanks, I will take care of it asap but only in trunk for next major release (5.2) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=766244&aid=1799048&group_id=146814 |