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

            Bug ID: 99608
           Summary: gcc doesn't print diagnostics carets when file is
                    passed through stdin
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: freezer at posteo dot de
  Target Milestone: ---

When a file is passed to gcc through stdin, gcc won't print any diagnostics
carets for the passed file.

Example:

// test.c
int main(int argc, char **argv)
{
    return 0;
}

When test.c is passed to gcc through stdin, the following is printed:

$ cat test.c | gcc -Wall -Wextra -xc -
<stdin>: In function ‘main’:
<stdin>:1:14: warning: unused parameter ‘argc’ [-Wunused-parameter]
<stdin>:1:27: warning: unused parameter ‘argv’ [-Wunused-parameter]

(Note that forcing the -fdiagnostics-show-caret option doesn't change anything)

I would have expected the same output as when the file is passed to gcc as an
argument:

$ gcc -Wall -Wextra test.c
test.c: In function ‘main’:
test.c:1:14: warning: unused parameter ‘argc’ [-Wunused-parameter]
    1 | int main(int argc, char **argv)
      |          ~~~~^~~~
test.c:1:27: warning: unused parameter ‘argv’ [-Wunused-parameter]
    1 | int main(int argc, char **argv)
      |                    ~~~~~~~^~~~

Reply via email to