Opened 11 years ago

Last modified 10 years ago

#5965 new Bugs

indirect_iterator conflicts with forward declaration

Reported by: Simon <simon.siemens@…> Owned by: jeffrey.hellrung
Milestone: To Be Determined Component: iterator
Version: Boost 1.46.1 Severity: Problem
Keywords: Cc: jeffrey.hellrung

Description

indirect_iterator, or more precisely its base class indirect_base, checks whether it can dereference its argument twice. This ends in an error, if the target type is incomplete (from a forward declaration). The error occurs even if the dereferencing is not used in the affected code unit. (It is concept checking.)

/usr/include/boost/detail/is_incrementable.hpp:84: error: cannot increment a pointer to incomplete type ‘Derived’

indirect_iterator handles pointers. Pointers and forward declaration should complete each other well. So indirect_iterator should never try to dereference if it is not forced by using code. Concept checking does not work here satisfactorily.

I appended exemplary code which I compiled with GCC 4.4.3.

Best regards,

Simon

Attachments (3)

Base.hpp (357 bytes ) - added by Simon <simon.siemens@…> 11 years ago.
The base class with a forward declaration and a range for a certain sub-class.
Derived.hpp (141 bytes ) - added by Simon <simon.siemens@…> 11 years ago.
The sub-class. A list of pointers to this class is saved in the base class.
main.cpp (64 bytes ) - added by Simon <simon.siemens@…> 11 years ago.
the main that puts everything together.

Download all attachments as: .zip

Change History (6)

by Simon <simon.siemens@…>, 11 years ago

Attachment: Base.hpp added

The base class with a forward declaration and a range for a certain sub-class.

by Simon <simon.siemens@…>, 11 years ago

Attachment: Derived.hpp added

The sub-class. A list of pointers to this class is saved in the base class.

by Simon <simon.siemens@…>, 11 years ago

Attachment: main.cpp added

the main that puts everything together.

comment:1 by jeffrey.hellrung, 10 years ago

The immediate problem actually appears to lie in boost::pointee, so one can partially specialize boost::pointee for pointer types to avoid instantiating is_incrementable. However, after doing this, a new problem arises with instantiating boost::is_POD on the value_type of the indirect_iterator (which, in this case, is Derived) during determination of the return type of operator[]. So, a possible resolution for your specific example would be to disable operator[] when the traversal of the underlying iterator is not random access. I'll see what I can do to effect this.

comment:2 by jeffrey.hellrung, 10 years ago

Cc: jeffrey.hellrung added

comment:3 by Dave Abrahams, 10 years ago

Owner: changed from Dave Abrahams to jeffrey.hellrung
Note: See TracTickets for help on using tickets.