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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2019-04-10
                 CC|                            |dmalcolm at gcc dot gnu.org
          Component|c                           |preprocessor
     Ever confirmed|0                           |1

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I see the odd

> tail /tmp/x
28769 stat("/usr/include/stdc-predef.h.gch", 0x7ffee0a9f9c0) = -1 ENOENT (No
such file or directory)
28769 open("/usr/include/stdc-predef.h", O_RDONLY|O_NOCTTY) = 3
28769 fstat(3, {st_mode=S_IFREG|0644, st_size=2495, ...}) = 0
28769 read(3, "/* Copyright (C) 1991-2015 Free "..., 2495) = 2495
28769 close(3)                          = 0
28769 mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x7f53c4cf9000
28769 open("/dev/stdout", O_RDONLY)     = 3
28769 fstat(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 16), ...}) = 0
28769 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x7f53c4cf8000
28769 read(3, 

so it reads from stdout!?

Ah, that's because of the input containing

#line 72 "/dev/stdout" /* yacc.c:315  */

if I "fix" that we get

stdout:84:9: error: no macro name given in #ifndef directive
stdout:84: error: unterminated #ifndef

so GCC wants to complain about

# ifndef YY_NULLPTR

and tries to apply caret diagnostics to that.  Opening /dev/stdout succeeds
but reading from it will hang.

Smaller testcase that will hang:

#line 1 "/dev/stdout"
#def xy


we should probably check whether the file we opened is a regular file
before trying to read from it.

That said, bison should be fixed to not emit this kind of line directives...

Reply via email to