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.
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)?
Confirmed. gcc 6, 7 and 8 are affected; gcc 5 is not affected.
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
GCC 6 branch is being closed
Fixed in GCC 8.