libstdc++/8780: std::vector iterators not recognized as pointers by templates in certain cases

johnb@stl.sarov.ru johnb@stl.sarov.ru
Mon Dec 2 01:06:00 GMT 2002


>Number:         8780
>Category:       libstdc++
>Synopsis:       std::vector iterators not recognized as pointers by templates in certain cases
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 02 01:06:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Eugeny Belov
>Release:        g++ (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
>Organization:
>Environment:
Red Hat Linux 8.0.
>Description:
  The attached testcase code uses STL to check whether the type given in the template specification of is_pointer_helper (in this case std::vector<int>::iterator) is a pointer type. (See also ISO\IEC 14882, 24.1.(1,2))
  So, trying to compile this testcase by g++ I get the error messages:
tr18877.cpp: In function `int main()':
tr18877.cpp:37: `sizeof' applied to incomplete type `
   STATIC_ASSERTION_FAILURE<false>'
tr18877.cpp:37: declaration does not declare anything
  The first error occure due the vector<int> iterator isn`t a pointer type, the second warning is legitimate.

>How-To-Repeat:
Try to compile the testcase with g++.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="veciter.cpp"
Content-Disposition: inline; filename="veciter.cpp"

#include <vector>
//#include <list>

template<int> struct static_assert_test{};

template <bool> struct STATIC_ASSERTION_FAILURE;
template <> struct STATIC_ASSERTION_FAILURE<true>{};

#define BOOST_STATIC_ASSERT( B ) static_assert_test<sizeof(STATIC_ASSERTION_FAILURE< ( B ) >)>

template <typename T> struct is_pointer_helper
{ static const bool value = false; };
template <typename T> struct is_pointer_helper<T*>
{ static const bool value = true; };
template <typename T> struct is_pointer_helper<T*const>
{ static const bool value = true; };
template <typename T> struct is_pointer_helper<T*volatile>
{ static const bool value = true; };
template <typename T> struct is_pointer_helper<T*const volatile>
{ static const bool value = true; };


int main(void)
{
	BOOST_STATIC_ASSERT(is_pointer_helper<std::vector<int>::iterator>::value);

	return(0);
}



More information about the Gcc-prs mailing list