[Bug c++/77922] Bogus suggestion: ‘constexpr’ does not name a type; did you mean ‘constexpr’?

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Oct 10 14:47:00 GMT 2016


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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
A similar thing happens with other C++11 keywords:

bad.cc:1:1: warning: identifier ‘decltype’ is a keyword in C++11
[-Wc++11-compat]
 decltype i = 0;
 ^~~~~~~~
bad.cc:1:1: error: ‘decltype’ does not name a type; did you mean ‘decltype’?
 decltype i = 0;
 ^~~~~~~~
 decltype

It's even worse in this case, because the code isn't valid even in C++11, so
the fix-it can never be a useful change.

(In reply to Jakub Jelinek from comment #0)
> I'd say we should just not print the bogus "did you mean" if the identifier
> fuzzy matching found is the same as the one used originally.  Or not add
> constexpr into the suggestions in this case because it is not C++98?

Not adding non-C++98 keywords into the suggestions make sense, and would solve
both of these examples. (Another option for the constexpr case would be to
suggest dropping the -std=c++98/-std=gnu++98/-std=c++03/-std=gnu++03/-ansi
option).

If there are still other ways that the match could end up being the same as the
original then suppressing the "did you mean" would still make sense.


More information about the Gcc-bugs mailing list