Welcome Guest! To access all forums & features, please register an account or sign-in. → Why register?




Photo - - - - -

g++'s error messages...

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):

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*’

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.)



Would clang produce the same error?

DJ Dark, on 27 September 2012 - 09:07, said:

Would clang produce the same error?
I have no experience with clang but from what I've seen in talks they strive to produce the most informative error messages possible. The entire compiler pipeline is written with informative error messages in mind. g++ ought to take some lessons or they might quickly be replaced.
Yeah, G++ messages are anything if not verbose. For the mostpart Visual Studio is pretty good with error messages normally, except when it decides to repeat the same error message 20 times or so.

The real fun comes when you write a bad template class. It's like picking through a garbage pile trying to find discarded gold.

It does annoy me that we're so far down the line, and I still have to copy/paste compiler output into notepad to track down the error.

Majesticmerc, on 27 September 2012 - 22:21, said:

For the mostpart Visual Studio is pretty good with error messages normally, except when it decides to repeat the same error message 20 times or so.The real fun comes when you write a bad template class.
My algorithm with Visual C++: fix the first error, recompile, repeat until it compiles. Any error beyond the first one is potentially garbage.
Hehe. That's nothing. Have you seen what happens when you make a mistake in using the STL? G++ just craps itself. Clang on the other hand, has useful error messages.

May 2013

S M T W T F S
   1234
567891011
12131415161718
1920 21 22232425
262728293031 

Categories