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


Follow @NeowinFeed
TwistedBrush Pro Studio v19.08 Released in Back Page News


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




+DJ Dark
Sep 27 2012 09:07
Would clang produce the same error?

+Dr_Asik
Sep 27 2012 22:02

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.

+Majesticmerc
Sep 27 2012 22:21
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.

+Dr_Asik
Sep 27 2012 23:47

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.

← October 2012 →

S M T W T F S
  1 23456
78910111213
14151617181920
21222324252627
28293031   

Recent Entries

  • Photo
    g++'s error messages...
    27 September 2012
  • Photo
    F# vs C#: when a functional approach wins over OOP
    27 August 2012
  • Photo
    Casts in C#
    18 August 2012
  • Photo
    The Catholic Church: A different look
    24 May 2012
  • Photo
    F#: exciting first impressions
    17 May 2012

Recent Comments

  • Photo
    g++'s error messages...
    By +Dr_Asik
    Sep 27 2012 23:47
  • Photo
    g++'s error messages...
    By +Majesticmerc
    Sep 27 2012 22:21
  • Photo
    g++'s error messages...
    By +Dr_Asik
    Sep 27 2012 22:02
  • Photo
    C#: why the best language still sucks
    By CobraCommander
    Sep 27 2012 10:29
  • Photo
    g++'s error messages...
    By +DJ Dark
    Sep 27 2012 09:07

Categories

  • -   Uncategorized (19)