This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/80177] New: wrong fixit hint for misspelled static_assert: __cpp_static_assert
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 24 Mar 2017 18:07:52 +0000
- Subject: [Bug c++/80177] New: wrong fixit hint for misspelled static_assert: __cpp_static_assert
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80177
Bug ID: 80177
Summary: wrong fixit hint for misspelled static_assert:
__cpp_static_assert
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
In the ill-formed test case below GCC suggests to replace the misspelled
static_assert with the __cpp_static_assert feature test macro rather than with
the static_assert keyword. Using the feature test macro here would be
incorrect to the hint should suggest the latter.
(I wonder if there is a way to have the algorithm prefer non-reserved names
over reserved ones. Also, it would be nice, though I suspect difficult, if the
algorithm could prefer names with the right type. E.g., prefer a function over
a literal where a the misspelled name looks like it's being used as a
function.)
$ cat a.C && gcc -S -Wall -Wextra -Wpedantic a.C
void f ()
{
static_assertion (1 == 0, "1 == 0");
}
a.C: In function ‘void f()’:
a.C:3:3: error: ‘static_assertion’ was not declared in this scope
static_assertion (1 == 0, "1 == 0");
^~~~~~~~~~~~~~~~
a.C:3:3: note: suggested alternative: ‘__cpp_static_assert’
static_assertion (1 == 0, "1 == 0");
^~~~~~~~~~~~~~~~
__cpp_static_assert