[Bug c/92720] cc1 accepts #include /dev/stdin inline

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Nov 30 23:44:00 GMT 2019


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

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Dennis Clarke from comment #7)
> Sort of a vague idea there. Whatever "can be" means.  However the file
> /dev/stdin really is neither a "header" nor is it a "source" file.

It could be. `echo "extern int i;"` would provide a valid source file to
standard input. "source file" does not mean "regular file on a physical disk".

> As people are saying, this is all "implementation" defined perhaps. I
> feel that no file shall be included if it is neither a "source" file
> nor a valid "header". No idea how one would verify such a condition at
> the pre-processing translation stage.

The compiler can't verify that. What's the difference between a header with a
syntax error (which we obviously want the compiler to *attempt* to compile, and
give a diagnostic) and a random file that isn't a header?

> That seems to imply I could just as easily do an include of /dev/random.

You can. Just don't expect it to compile.

This seems like a case of "play stupid games, win stupid prizes".


More information about the Gcc-bugs mailing list