[Bug c++/85958] Make const qualifier error clear
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Jun 3 19:43:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85958
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(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.
>
> 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.
> 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.
I'm keen to make the language clearer, but not by making it simply wrong about
what's happening!
More information about the Gcc-bugs
mailing list