[Bug c++/61587] Line number of code that triggers "use of deleted function" error is absent from error message

Marc.van-Leeuwen at math dot univ-poitiers.fr gcc-bugzilla@gcc.gnu.org
Tue Jun 24 03:40:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61587

--- Comment #2 from Marc van Leeuwen <Marc.van-Leeuwen at math dot univ-poitiers.fr> ---
But the error in this program is so much not with the implicitly declared copy
constructor of A itself (I suppose it is "A::A (const &A)" that the compiler is
trying to generate here) but with the fact that the code is (accidentally)
_using_ that copy constructor. That usage in done in the indicated line 18, and
without that line the program compiles correctly. I agree that it might have
been better to explicitly mark that implicitly-declared copy constructor as
deleted in the class definition of A, but one does not _have to_ do that, as
long as such a copy constructor is not being used anywhere.

So the compiler must have been reading at least up to line 18 before it decided
to emit this error message; my complaint is just that _nothing_ in the list of
error message gies any indication of that. I would think C++ compilation is
basically a single-pass process, and that it would be rather easy for a
compiler to start (or end) each error message with an indication of exactly
where it is during this pass; in my experience with gcc such an indication
sometimes comes in the middle of a long sequence of messages, which is fine
with me too, but in this particular case such indication seems to be entirely
absent.

In practice such illegal copy-constructing of an A object could happen in code
very far from the class definition; how is a user going to trace the place
where she did so?



More information about the Gcc-bugs mailing list