Closed gopherbot closed 9 years ago
The errors are: y.tab.c:5203:9: error: passing argument 1 of 'yyerror' discards 'const' qualifier from pointer target type [-Werror] /home/milkline/go/src/cmd/gc/go.h:1148:6: note: expected 'char *' but argument is of type 'const char *' Nothing has changed in gcc. More likely is a change in bison. What version of bison are you using? What is line 5203 of the file src/cmd/gc/y.tab.c?
The Go tree's C code assumes that you can pass a string literal "hello" to a function expecting a char*. Gcc appears to want you to pass such string literals only to functions expecting const char*. I don't know why this would have started showing up now. Either we have to fix the tree or we have to find a compiler flag that we can rely on even in old gcc to silence the error. Russ
gcc does not warn about passing a string literal to a function which expects char*, unless you use the -Wwrite-strings option which quietgcc does not do. There are in any case many calls passing a string literal to yyerror, but the reported output only has one error. So it's not a matter of passing a string literal. It's something else, but I don't know what it is, because I don't know what that line in y.tab.c looks like. Line 5203 in my y.tab.c, generated by bison 2.4.1, has nothing close by which calls yyerror.
Thanks. I built bison 2.5 and I can confirm that it pass a const char * variable to yyerror, which is where this warning is coming from. As far as I can see, we can either extend the sed command which creates y1.tab.c to remove the "const", or we can change yyerror to accept const char *. E.g., adding this to the sed command works around the problem: s/char const \*yymsgp/char *yymsgp/
by milkline: