Possible range based 'for' bug

Julian Klappenbach jklappenbach@gmail.com
Sun Jun 21 15:56:00 GMT 2015

Version info:

Configured with:
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix

I'm using the default build provided by brew.  If you need more
information, I'd be happy to provide it.

The issue:

I've been working on a new framework library, and with iterators that
would be able to take advantage of c++'s range-based for loop.  The
API requires that I adhere to std's iterators, supporting begin and
end, as well as ++ and * operators.

Since I have many different types of iterators, I had created a basic
interface to pass them around, an abstract virtual class with pure
virtual members.  The problem occurs when the logic behind the range
based for loop calls begin, and receives the pure virtual base class
of the iterator.  This causes the compiler error:

../src/ListTests.cpp:156:13: error: variable type 'Iterable<int>' is
an abstract class
        for (int x : aList.values()) {

Would it be possible for the logic in the ranged-for loop to check for
a v-table, and execute polymorphic calls?  If not, there are
mitigating (non-ideal) strategies that I could use.  However, I
thought it would be worth asking, and if this is deemed a bug, go
through the effort of posting an entry to bug tracker.

Thanks for your time,


More information about the Gcc mailing list