[Bug c/84195] New: newlines in deprecated diagnostics

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Feb 3 23:16:00 GMT 2018


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

            Bug ID: 84195
           Summary: newlines in deprecated diagnostics
           Product: gcc
           Version: 8.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: ---

The deprecated attribute makes it possible for GCC diagnostics to be broken up
by newlines introduced by the program.  I think it would better to remove
newlines and other control characters from the string before printing it so
that they don't mess up tools that parse GCC output.  If there's no limit on
the length of the string it might also be worthwhile to impose it.

$ cat t.C && gcc -O -S -Wall -Wextra t.C
#define MSG "\nThis is deprecated.\nPlease do not use it.\n"

int f (int i __attribute__ ((deprecated (MSG))))
{
  return 0 ? i : 0;
}

void g (int i)
{
  f (i);
}
t.C: In function ‘int f(int)’:
t.C:5:14: warning: ‘i’ is deprecated: 
This is deprecated.
Please do not use it.
    [-Wdeprecated-declarations]
   return 0 ? i : 0;
              ^
t.C:3:12: note: declared here
 int f (int i __attribute__ ((deprecated (MSG))))
        ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


More information about the Gcc-bugs mailing list