Bug 84034 - [7 Regression] incomplete warning message with dos line endings
Summary: [7 Regression] incomplete warning message with dos line endings
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 8.0
: P2 normal
Target Milestone: 8.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2018-01-25 08:16 UTC by Bernd Edlinger
Modified: 2019-11-14 11:01 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 8.0
Known to fail: 7.5.0
Last reconfirmed: 2018-01-26 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bernd Edlinger 2018-01-25 08:16:51 UTC
cat test.c
extern int a,b,c,d,e,f;
int test()
{
  if ((!a && b > c) ||
      (d && b > e) &&
      f)
    return 1;
  return 0; 
}

gcc -Wall -c test.c
test.c: In function ‘test’:
test.c:5:20: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]

       ~~~~~~~~~~~~~^~~
       f)
       ~             

NOTE: test.c is with DOS line endings!!!!
open it in vi, say ":set ff=dos" save.

The warning prints both lines correctly with ff=unix.
Comment 1 Bernd Edlinger 2018-01-25 09:10:13 UTC
it is acutally a problem with the colorizer:

gcc -fdiagnostics-color=always -Wall -S test.c 2> xx

cat xx
test.c: In function ‘test’:
test.c:5:20: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]

       ~~~~~~~~~~~~~^~~
       f)
       ~             

cat xx|tr "\r" " "
test.c: In function ‘test’:
test.c:5:20: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
       (d && b > e) && 
       ~~~~~~~~~~~~~^~~
       f) 
       ~             


so the missing line is quickly overprinted, because the color is swithed off
between CR and LF, by replacing CR with SPACE the print out looks correct.

How about replacing all CR with SPACE (like the TAB is also done IIRC)?
Comment 2 David Malcolm 2018-01-26 21:25:32 UTC
Confirmed.  gcc 6, 7 and 8 are affected; gcc 5 is not affected.
Comment 3 Bernd Edlinger 2018-01-27 06:44:57 UTC
Author: edlinger
Date: Sat Jan 27 06:44:25 2018
New Revision: 257120

URL: https://gcc.gnu.org/viewcvs?rev=257120&root=gcc&view=rev
Log:
2018-01-27  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR diagnostic/84034
        * diagnostic-show-locus.c (get_line_width_without_trailing_whitespace):
        Handle CR like TAB.
        (layout::print_source_line): Likewise.
        (test_get_line_width_without_trailing_whitespace): Add test cases.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/diagnostic-show-locus.c
Comment 4 Jakub Jelinek 2018-10-26 10:13:45 UTC
GCC 6 branch is being closed
Comment 5 Richard Biener 2019-11-14 11:01:27 UTC
Fixed in GCC 8.