[Bug c++/80684] poor error message and fix-it hint for a function with an argument of undeclared type
egallager at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Aug 18 18:49:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80684
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-08-18
CC| |egallager at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
For me the fix-it is just:
$ /usr/local/bin/g++ -S -Wall -Wextra -pedantic 80684.cc
80684.cc:1:15: error: variable or field ‘f’ declared void
void f (string);
^
80684.cc:1:9: error: ‘string’ was not declared in this scope
void f (string);
^~~~~~
80684.cc:1:9: note: suggested alternative: ‘__strong’
void f (string);
^~~~~~
__strong
$
When I include the header, the message is:
$ /usr/local/bin/g++ -S -Wall -Wextra -pedantic 80684.cc
80684.cc:3:15: error: variable or field ‘f’ declared void
void f (string);
^
80684.cc:3:9: error: ‘string’ was not declared in this scope
void f (string);
^~~~~~
80684.cc:3:9: note: suggested alternative:
In file included from /usr/local/include/c++/8.0.0/string:39:0,
from 80684.cc:1:
/usr/local/include/c++/8.0.0/bits/stringfwd.h:74:33: note:
‘std::__cxx11::string’
typedef basic_string<char> string;
^~~~~~
$
It seems like in this second case where <string> is already included, the ideal
fix-it would be to suggest inserting the 'std::' prefix before 'string', or
adding a "using namespace std;" directive earlier in the file. Thus,
confirming.
More information about the Gcc-bugs
mailing list