[Bug c++/39728] diagnostic for private operator= is voluminous and unhelpful

manu at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Apr 16 11:34:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39728

--- Comment #6 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-04-16 11:34:01 UTC ---
(In reply to comment #5)
> /home/redi/gcc/4.x/include/c++/4.8.0/bits/ios_base.h: In member function
> 'std::basic_ios<char>& std::basic_ios<char>::operator=(const
> std::basic_ios<char>&)':
> 
> This is useful info, it tells me the (implicitly-defined) context in which the
> private operator= was needed.

OK, the info maybe be useful. I think the way to show it could be better. But
the major improvement would be the typedefs preservation.

> 
> /home/redi/gcc/4.x/include/c++/4.8.0/bits/ios_base.h:791:5: error:
> 'std::ios_base& std::ios_base::operator=(const std::ios_base&)' is private
>      operator=(const ios_base&);
>      ^
> 
> This is useful, it's the private operator= that was needed, but inaccessible.

Indeed! I was in a hurry, but this information should be in the "because
[reason]" part of my ideal output above. My point (and Ian's in comment #1) is
that the error is that the implicitly-defined methods cannot be called/created
(and this should be mentioned first) and the reason is that = is inaccessible
(and this should be mentioned later).

> In file included from /home/redi/gcc/4.x/include/c++/4.8.0/ios:45:0,
>                  from /home/redi/gcc/4.x/include/c++/4.8.0/istream:40,
>                  from /home/redi/gcc/4.x/include/c++/4.8.0/fstream:40,
>                  from f.cc:1:
> /home/redi/gcc/4.x/include/c++/4.8.0/bits/basic_ios.h:64:11: error: within this
> context
>      class basic_ios : public ios_base
>            ^
> 
> The caret diagnostic is useless here, because an implictly-defined function has
> no location.

No, the location is useless (or the error is wrongly stated). The caret just
shows where the error message is pointing to the user. And also, it should not
be an error, but a note.



More information about the Gcc-bugs mailing list