This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/85958] Make const qualifier error clear


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

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to W E Brown from comment #8)
> (2) For the same reason, the note accompanying the diagnostic might at the
> same time be more accurately rephrased as "initializing parameter 1 of ..."
> instead of the current "initializing argument 1 of ...".

Agreed.

> (3) Finally, there seems to be a fair amount of redundancy in the note,
> mentioning the called function both with and without its parameter's name. 
> Perhaps just one of these might suffice?

The first occurrence is the function type (including any template arguments),
and is always shown. The second is the verbatim line from the source code
highlighted with carets, but is only shown conditionally (caret diagnostics can
be disabled with -fno-diagnostics-show-caret) and might not show the entire
function declaration. For example:

template<typename T>                                                            
void f(int,                                                                     
       T&)                                                                      
{ }                                                                             

int main()                                                                      
{                                                                               
  f(1, 1);
}


f.cc: In function ‘int main()’:
f.cc:8:9: error: cannot bind non-const lvalue reference of type ‘int&’ to an
rvalue of type ‘int’
   f(1, 1);
         ^
f.cc:2:6: note:   initializing argument 2 of ‘void f(int, T&) [with T = int]’
 void f(int,
      ^

Removing the note here would mean losing valuable information (the caret
diagnostic doesn't show the right line, which is a separate bug, but even with
that fixed would only show one line not the whole function declaration).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]