This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

libstdc++/2504: Problems with the new checking code (boost)



>Number:         2504
>Category:       libstdc++
>Synopsis:       Problems with the new checking code (boost)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 06 18:26:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Peter Schmid
>Release:        3.1 20010406 (experimental)
>Organization:
TU Darmstadt
>Environment:
System: Linux kiste 2.4.3 #35 Sat Mar 31 22:08:25 CEST 2001 i686 unknown
Architecture: i686
SuSE 7.1
glibc 2.2
GNU ld version 2.11.90.0.4 (with BFD 2.11.90.0.4)
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-long-long --enable-languages=c,c++,f77,objc
>Description:
The following code, a stripped down version of
lib/concept_check/concept_check_est.cpp from boost 1_21_1/, exposes a
problem which occurs with the new checking code. 
After the intermediate result
#ifndef BOOST_CONCEPT_CHECKS_HPP
#define BOOST_CONCEPT_CHECKS_HPP
#     include <iterator>
#endif
I reduced the code further to the following t.C source code. If I remove
the #ifndef BOOST_CONCEPT_CHECKS_HPP guards the code compiles without
a warning. If the guards are in place, the strange compiler
message t.C:15: parse error before `::' token results. Furthermore, I
note, that boost::function_requires is not defined in the compilation unit.
That is because of t.C defines BOOST_CONCEPT_CHECKS_HPP and
therefore <bits/boost_concept_check.h> is not included. But if the  
the unmodified file lib/concept_check/concept_check_est.cpp is
compiled exactly the same message occurs (parse error before::).  
Maybe the functions and macros defined in <bits/boost_concept_check.h> and
boost/boost_concept_check.h are incompatible and the name of the
guard of the libstdc++ header file should be changed.  
 
>How-To-Repeat:
Source code t.C

#ifndef BOOST_CONCEPT_CHECKS_HPP
#define BOOST_CONCEPT_CHECKS_HPP
//#     include <iterator>
#include <bits/std_cstddef.h>
#include <bits/stl_iterator_base_types.h>
#include <bits/concept_check.h>

namespace std
{
template <class _InputIterator, class _Distance>
inline void __distance(_InputIterator __first, _InputIterator __last,
                       _Distance& __n, input_iterator_tag)
{
  // concept requirements
  glibcpp_function_requires(InputIteratorConcept<_InputIterator>);
  while (__first != __last) { ++__first; ++__n; }
}

} // namespace std

#endif

Compiling t.C
>Fix:
g++ -v -c t.C -W -Wall -save-temps
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-long-long --enable-languages=c,c++,f77,objc
gcc version 3.1 20010406 (experimental)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cpp0 -lang-c++ -D_GNU_SOURCE -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -W -Wall -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ t.C t.ii
GNU CPP version 3.1 20010406 (experimental) (cpplib) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/g++-v3
 /usr/local/include/g++-v3/i686-pc-linux-gnu
 /usr/local/include/g++-v3/backward
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include
 /usr/local/i686-pc-linux-gnu/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cc1plus -fpreprocessed t.ii -quiet -dumpbase t.C -W -Wall -version -o t.s
GNU CPP version 3.1 20010406 (experimental) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.1 20010406 (experimental) (i686-pc-linux-gnu)
	compiled by GNU C version 3.1 20010406 (experimental).
t.C: In function `void std::__distance(_InputIterator, _InputIterator, 
   _Distance&, std::input_iterator_tag)':
t.C:15: parse error before `::' token

preprocessed source code t.ii
# 4 "t.C"
# 1 "/usr/local/include/g++-v3/bits/std_cstddef.h" 1 3
# 40 "/usr/local/include/g++-v3/bits/std_cstddef.h" 3
# 1 "/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include/stddef.h" 1 3
# 147 "/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include/stddef.h" 3
typedef int ptrdiff_t;
# 199 "/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include/stddef.h" 3
typedef unsigned int size_t;
# 41 "/usr/local/include/g++-v3/bits/std_cstddef.h" 2 3

namespace std
{
  using ::ptrdiff_t;
  using ::size_t;
}
# 5 "t.C" 2
# 1 "/usr/local/include/g++-v3/bits/stl_iterator_base_types.h" 1 3
# 40 "/usr/local/include/g++-v3/bits/stl_iterator_base_types.h" 3

namespace std
{

struct input_iterator_tag {};
struct output_iterator_tag {};
struct forward_iterator_tag : public input_iterator_tag {};
struct bidirectional_iterator_tag : public forward_iterator_tag {};
struct random_access_iterator_tag : public bidirectional_iterator_tag {};






template <class _Tp, class _Distance> struct input_iterator {
  typedef input_iterator_tag iterator_category;
  typedef _Tp value_type;
  typedef _Distance difference_type;
  typedef _Tp* pointer;
  typedef _Tp& reference;
};

struct output_iterator {
  typedef output_iterator_tag iterator_category;
  typedef void value_type;
  typedef void difference_type;
  typedef void pointer;
  typedef void reference;
};

template <class _Tp, class _Distance> struct forward_iterator {
  typedef forward_iterator_tag iterator_category;
  typedef _Tp value_type;
  typedef _Distance difference_type;
  typedef _Tp* pointer;
  typedef _Tp& reference;
};


template <class _Tp, class _Distance> struct bidirectional_iterator {
  typedef bidirectional_iterator_tag iterator_category;
  typedef _Tp value_type;
  typedef _Distance difference_type;
  typedef _Tp* pointer;
  typedef _Tp& reference;
};

template <class _Tp, class _Distance> struct random_access_iterator {
  typedef random_access_iterator_tag iterator_category;
  typedef _Tp value_type;
  typedef _Distance difference_type;
  typedef _Tp* pointer;
  typedef _Tp& reference;
};

template <class _Category, class _Tp, class _Distance = ptrdiff_t,
          class _Pointer = _Tp*, class _Reference = _Tp&>
struct iterator {
  typedef _Category iterator_category;
  typedef _Tp value_type;
  typedef _Distance difference_type;
  typedef _Pointer pointer;
  typedef _Reference reference;
};

template <class _Iterator>
struct iterator_traits {
  typedef typename _Iterator::iterator_category iterator_category;
  typedef typename _Iterator::value_type value_type;
  typedef typename _Iterator::difference_type difference_type;
  typedef typename _Iterator::pointer pointer;
  typedef typename _Iterator::reference reference;
};

template <class _Tp>
struct iterator_traits<_Tp*> {
  typedef random_access_iterator_tag iterator_category;
  typedef _Tp value_type;
  typedef ptrdiff_t difference_type;
  typedef _Tp* pointer;
  typedef _Tp& reference;
};

template <class _Tp>
struct iterator_traits<const _Tp*> {
  typedef random_access_iterator_tag iterator_category;
  typedef _Tp value_type;
  typedef ptrdiff_t difference_type;
  typedef const _Tp* pointer;
  typedef const _Tp& reference;
};
# 140 "/usr/local/include/g++-v3/bits/stl_iterator_base_types.h" 3
template <class _Iter>
inline typename iterator_traits<_Iter>::iterator_category
__iterator_category(const _Iter&)
{
  typedef typename iterator_traits<_Iter>::iterator_category _Category;
  return _Category();
}

template <class _Iter>
inline typename iterator_traits<_Iter>::difference_type*
__distance_type(const _Iter&)
{
  return static_cast<typename iterator_traits<_Iter>::difference_type*>(0);
}

template <class _Iter>
inline typename iterator_traits<_Iter>::value_type*
__value_type(const _Iter&)
{
  return static_cast<typename iterator_traits<_Iter>::value_type*>(0);
}

template <class _Iter>
inline typename iterator_traits<_Iter>::iterator_category
iterator_category(const _Iter& __i) { return __iterator_category(__i); }


template <class _Iter>
inline typename iterator_traits<_Iter>::difference_type*
distance_type(const _Iter& __i) { return __distance_type(__i); }

template <class _Iter>
inline typename iterator_traits<_Iter>::value_type*
value_type(const _Iter& __i) { return __value_type(__i); }

}
# 6 "t.C" 2
# 1 "/usr/local/include/g++-v3/bits/concept_check.h" 1 3
# 34 "/usr/local/include/g++-v3/bits/concept_check.h" 3
# 1 "/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/c++config.h" 1 3
# 34 "/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/c++config.h" 3
# 1 "/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/os_defines.h" 1 3
# 43 "/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/os_defines.h" 3
# 1 "/usr/include/features.h" 1 3
# 283 "/usr/include/features.h" 3
# 1 "/usr/include/sys/cdefs.h" 1 3
# 284 "/usr/include/features.h" 2 3
# 311 "/usr/include/features.h" 3
# 1 "/usr/include/gnu/stubs.h" 1 3
# 312 "/usr/include/features.h" 2 3
# 44 "/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/os_defines.h" 2 3
# 35 "/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/c++config.h" 2 3
# 35 "/usr/local/include/g++-v3/bits/concept_check.h" 2 3
# 66 "/usr/local/include/g++-v3/bits/concept_check.h" 3
# 1 "/usr/local/include/g++-v3/bits/boost_concept_check.h" 1 3
# 67 "/usr/local/include/g++-v3/bits/concept_check.h" 2 3
# 7 "t.C" 2

namespace std
{
template <class _InputIterator, class _Distance>
inline void __distance(_InputIterator __first, _InputIterator __last,
                       _Distance& __n, input_iterator_tag)
{

  boost::function_requires< boost::InputIteratorConcept<_InputIterator> >();
  while (__first != __last) { ++__first; ++__n; }
}

}

	<How to correct or work around the problem, if known (multiple lines)>
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]