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

--- Comment #10 from Jonny Grant <jg at jguk dot org> ---
(In reply to Jonathan Wakely from comment #7)
> (In reply to Jonny Grant from comment #5)
> > I personally feel "bind" is not a word any programming course teaches, we
> > say "passing parameters" or "passing arguments".
> 
> You pass arguments, which initialize parameters. Initialization of
> references is called binding.

Our C++ lectures always said "pass by reference". A quick search online seems
to say similar. Although I appreciate compiler developers will always use more
formally accurate terms.

https://stackoverflow.com/questions/373419/whats-the-difference-between-passing-by-reference-vs-passing-by-value


> > 
> > In addition, I feel we don't think we really need the word "reference"
> 
> If the parameter type wasn't a reference there would be no problem. Omitting
> the reason it fails seems unhelpful.

My reasoning for not listing the word "reference" is that "int&" includes the
symbol & which means reference.   But a little duplication is ok.. only one
word.

> > Therefore, I suggest the following:
> > 
> > $ g++ -o main main.cpp -Wall -Werror -Wconversion
> > main.cpp: In function ‘int main()’:
> > main.cpp:11:25: error: cannot pass ‘const int’ to non-const ‘int&’
> 
> No this is nonsense. You are not passing something to a reference, you are
> passing it to the function. The object cannot be bound to the reference
> because of the cv-qualifiers.

Ok, point taken you are right.

So this I suggest:
 main.cpp:11:25: error: cannot pass ‘const int’ by non-const ‘int&’

Or with the "reference" word:
 main.cpp:11:25: error: cannot pass ‘const int’ by non-const ‘int&’ reference.

Although i do like W E Brown suggestion, I took out the "type":

"can't initialize parameter reference 'int&' with argument 'const int'"

> I'm keen to make the language clearer, but not by making it simply wrong
> about what's happening!

great! :)

Reply via email to