https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92995
Bug ID: 92995
Summary: -Wmisleading-indentation and multiline string literals
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: palves at redhat dot com
Target Milestone: ---
clang 10 caught a misleading indentation in gdb that GCC missed:
https://sourceware.org/ml/gdb-patches/2019-12/msg00733.html
It appears that the issue is the line continuation in the string literal.
Here's a minimal reproducer:
$ cat indentation.c
void g (const char *);
void f1 (void)
{
if (1)
g ("hello\n");
g ("\n"); // warns
}
void f2 (void)
{
if (1)
g ("hello\
\n");
g ("\n"); // does not warn
}
$ /opt/gcc/bin/gcc -c -Wall indentation.c
indentation.c: In function ‘f1’:
indentation.c:5:3: warning: this ‘if’ clause does not guard...
[-Wmisleading-indentation]
5 | if (1)
| ^~
indentation.c:7:5: note: ...this statement, but the latter is misleadingly
indented as if it were guarded by the ‘if’
7 | g ("\n"); // warns
| ^
$ /opt/gcc/bin/gcc --version
gcc (GCC) 10.0.0 20191218 (experimental)