The g++ team really needs to work on its compiler error messages. Real-world example, 2 minutes ago. Compiling the following class for use with Intel's Thread Building Blocks (parallel_for to be precise):
Yields the following error:
5 years of C++ experience tell me this wall of text means I'm missing a const qualifier on my copy constructor. I just wish the compiler would tell me that, and nothing else.
(Yes there are several bugs and problems with this class. It's a work-in-progress.)
class DragonDraw {
struct draw_data* _data;
int id;
public:
DragonDraw(draw_data* data) : _data(data), id(0) {}
DragonDraw(DragonDraw& d) : id(d.getId() + 1) {}
void operator()(const blocked_range<size_t>& r) const {
struct draw_data *info = (struct draw_data *) _data;
dragon_draw_raw(r.begin(), r.end(), info->dragon, info->dragon_width, info->dragon_height, info->limits, id);
}
int getId() const { return id; }
};
Yields the following error:
Quote
CXX dragon_tbb.o
In file included from /usr/include/tbb/tbb.h:57:0,
from dragon_tbb.cpp:16:
/usr/include/tbb/parallel_for.h: In constructor ‘tbb::internal::start_for<Range, Body, Partitioner>::start_for(const Range&, const Body&, Partitioner&) [with Range = tbb::blocked_range<unsigned int>, Body = DragonDraw, Partitioner = tbb::auto_partitioner]’:
/usr/include/tbb/parallel_for.h:81:125: instantiated from ‘static void tbb::internal::start_for<Range, Body, Partitioner>::run(const Range&, const Body&, const Partitioner&) [with Range = tbb::blocked_range<unsigned int>, Body = DragonDraw, Partitioner = tbb::auto_partitioner]’
/usr/include/tbb/parallel_for.h:132:5: instantiated from ‘void tbb::parallel_for(const Range&, const Body&) [with Range = tbb::blocked_range<unsigned int>, Body = DragonDraw]’
dragon_tbb.cpp:124:102: instantiated from here
/usr/include/tbb/parallel_for.h:56:37: error: no matching function for call to ‘DragonDraw::DragonDraw(const DragonDraw&)’
/usr/include/tbb/parallel_for.h:56:37: note: candidates are:
dragon_tbb.cpp:57:2: note: DragonDraw::DragonDraw(DragonDraw&)
dragon_tbb.cpp:57:2: note: no known conversion for argument 1 from ‘const DragonDraw’ to ‘DragonDraw&’
dragon_tbb.cpp:56:2: note: DragonDraw::DragonDraw(draw_data*)
dragon_tbb.cpp:56:2: note: no known conversion for argument 1 from ‘const DragonDraw’ to ‘draw_data*’
/usr/include/tbb/parallel_for.h: In constructor ‘tbb::internal::start_for<Range, Body, Partitioner>::start_for(tbb::internal::start_for<Range, Body, Partitioner>&, tbb::split) [with Range = tbb::blocked_range<unsigned int>, Body = DragonDraw, Partitioner = tbb::auto_partitioner, tbb::internal::start_for<Range, Body, Partitioner> = tbb::internal::start_for<tbb::blocked_range<unsigned int>, DragonDraw, tbb::auto_partitioner>]’:
/usr/include/tbb/parallel_for.h:106:78: instantiated from ‘tbb::task* tbb::internal::start_for<Range, Body, Partitioner>::execute() [with Range = tbb::blocked_range<unsigned int>, Body = DragonDraw, Partitioner = tbb::auto_partitioner]’
dragon_tbb.cpp:164:1: instantiated from here
/usr/include/tbb/parallel_for.h:64:54: error: no matching function for call to ‘DragonDraw::DragonDraw(const DragonDraw&)’
/usr/include/tbb/parallel_for.h:64:54: note: candidates are:
dragon_tbb.cpp:57:2: note: DragonDraw::DragonDraw(DragonDraw&)
dragon_tbb.cpp:57:2: note: no known conversion for argument 1 from ‘const DragonDraw’ to ‘DragonDraw&’
dragon_tbb.cpp:56:2: note: DragonDraw::DragonDraw(draw_data*)
dragon_tbb.cpp:56:2: note: no known conversion for argument 1 from ‘const DragonDraw’ to ‘draw_data*’
In file included from /usr/include/tbb/tbb.h:57:0,
from dragon_tbb.cpp:16:
/usr/include/tbb/parallel_for.h: In constructor ‘tbb::internal::start_for<Range, Body, Partitioner>::start_for(const Range&, const Body&, Partitioner&) [with Range = tbb::blocked_range<unsigned int>, Body = DragonDraw, Partitioner = tbb::auto_partitioner]’:
/usr/include/tbb/parallel_for.h:81:125: instantiated from ‘static void tbb::internal::start_for<Range, Body, Partitioner>::run(const Range&, const Body&, const Partitioner&) [with Range = tbb::blocked_range<unsigned int>, Body = DragonDraw, Partitioner = tbb::auto_partitioner]’
/usr/include/tbb/parallel_for.h:132:5: instantiated from ‘void tbb::parallel_for(const Range&, const Body&) [with Range = tbb::blocked_range<unsigned int>, Body = DragonDraw]’
dragon_tbb.cpp:124:102: instantiated from here
/usr/include/tbb/parallel_for.h:56:37: error: no matching function for call to ‘DragonDraw::DragonDraw(const DragonDraw&)’
/usr/include/tbb/parallel_for.h:56:37: note: candidates are:
dragon_tbb.cpp:57:2: note: DragonDraw::DragonDraw(DragonDraw&)
dragon_tbb.cpp:57:2: note: no known conversion for argument 1 from ‘const DragonDraw’ to ‘DragonDraw&’
dragon_tbb.cpp:56:2: note: DragonDraw::DragonDraw(draw_data*)
dragon_tbb.cpp:56:2: note: no known conversion for argument 1 from ‘const DragonDraw’ to ‘draw_data*’
/usr/include/tbb/parallel_for.h: In constructor ‘tbb::internal::start_for<Range, Body, Partitioner>::start_for(tbb::internal::start_for<Range, Body, Partitioner>&, tbb::split) [with Range = tbb::blocked_range<unsigned int>, Body = DragonDraw, Partitioner = tbb::auto_partitioner, tbb::internal::start_for<Range, Body, Partitioner> = tbb::internal::start_for<tbb::blocked_range<unsigned int>, DragonDraw, tbb::auto_partitioner>]’:
/usr/include/tbb/parallel_for.h:106:78: instantiated from ‘tbb::task* tbb::internal::start_for<Range, Body, Partitioner>::execute() [with Range = tbb::blocked_range<unsigned int>, Body = DragonDraw, Partitioner = tbb::auto_partitioner]’
dragon_tbb.cpp:164:1: instantiated from here
/usr/include/tbb/parallel_for.h:64:54: error: no matching function for call to ‘DragonDraw::DragonDraw(const DragonDraw&)’
/usr/include/tbb/parallel_for.h:64:54: note: candidates are:
dragon_tbb.cpp:57:2: note: DragonDraw::DragonDraw(DragonDraw&)
dragon_tbb.cpp:57:2: note: no known conversion for argument 1 from ‘const DragonDraw’ to ‘DragonDraw&’
dragon_tbb.cpp:56:2: note: DragonDraw::DragonDraw(draw_data*)
dragon_tbb.cpp:56:2: note: no known conversion for argument 1 from ‘const DragonDraw’ to ‘draw_data*’
5 years of C++ experience tell me this wall of text means I'm missing a const qualifier on my copy constructor. I just wish the compiler would tell me that, and nothing else.
(Yes there are several bugs and problems with this class. It's a work-in-progress.)







