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

            Bug ID: 92720
           Summary: cc1 accepts #include /dev/stdin inline
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dclarke at blastwave dot org
  Target Milestone: ---

Strangely I see recent cc1 accept this : 

/* echo '"hell"' | cc -o tmp tmp.c && ./tmp */
#include <stdio.h>

int main(void) {
        printf("%s\n",
#include"/dev/stdin"
        );
}

For example this is accepted :

$ echo '\042hello botfelk\\n\042' | gcc -m64 -std=iso9899:1999 \
> -pedantic -pedantic-errors -Wpedantic -fno-builtin -O0 -v \
> -o /tmp/botfelk /tmp/botfelk.c


That is considered acceptable whereas Oracle Studio 12.6 c99 
clearly complains : 

beta$ echo '\042hello botfelk\\n\042' | $CC $CFLAGS $CPPFLAGS -\# -H -o
/tmp/botfelk /tmp/botfelk.c
### c99: Note: NLSPATH =
/opt/developerstudio12.6/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/developerstudio12.6/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat
### c99: Note: TMPDIR = /var/tmp/dclarke
###     command line files and options (expanded):
### -m64 -xarch=sparc -Xc -xdebuginfo=line,param,variable,tagtype,codetag,decl
-xglobalize=yes -xpatchpadding=fix -xkeep_unref=funcs,vars -mc -xs=yes
-errfmt=error -erroff=%none -errshort=full -errtags=yes -errwarn=%none
-ftrap=%none -xbuiltin=%none -xlibmieee -xstrconst -xcode=pic32 -xmemalign=8s
-xnolibmil -xunroll=1 -xregs=no%appl -xdebugformat=dwarf -I/usr/local/include
-D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE -D_TS_ERRNO
-D_XOPEN_SOURCE=600 -# -H -o/tmp/botfelk /tmp/botfelk.c
/opt/developerstudio12.6/lib/compilers/bin/acomp -D_POSIX_PTHREAD_SEMANTICS
-D_LARGEFILE64_SOURCE -D_TS_ERRNO -D_XOPEN_SOURCE=600 -H -Qy -Xc -xc99=%all
-features=no%mergestrings,extinl,no%typeof,no%extensions,conststrings,no%zla,no%iddollar,no%gcc_enums
-i /tmp/botfelk.c -D__SunOS_5_10 -D__SunOS_RELEASE=0x051000 -D__SUNPRO_C=0x5150
-D__unix -D__SVR4__ -D__svr4__ -D__SVR4 -D__sun -D__sun__ -D__SunOS -D__sparcv9
-D__sparc_v9__ -D__sparc -D__sparc__ -D_LP64 -D__LP64__ -D__arch64__
-D__ORDER_LITTLE_ENDIAN__=1234 -D__ORDER_BIG_ENDIAN__=4321
-D__BYTE_ORDER__=__ORDER_BIG_ENDIAN__ -D__BUILTIN_VA_ARG_INCR -D__C99FEATURES__
-D__PRAGMA_REDEFINE_EXTNAME -D__FLT_EVAL_METHOD__=0 -D__SUN_PREFETCH
-I/usr/local/include -I-xbuiltin
-I/opt/developerstudio12.6/lib/compilers/include/cc -I/usr/xpg6/include
-I/usr/xpg4/include -2K -errfmt=error -erroff=%none -errshort=full
-errwarn=%none -errtags -xwarn_include_dir=permission -xbuiltin=%none -strconst
-fsimple=0 -m64 -fparam_ir -fparam_ir -xglobalize=yes
-xdebuginfo=line,param,variable,tagtype,codetag,decl -xkeep_unref=funcs,vars
-xF=%none -xdbggen=dwarf+usedonly+incl+line+param+variable+tagtype+codetag+decl
-xldscope=global -xivdep=loop -xanalyze=code -c99OS
"-g/opt/developerstudio12.6/bin/c99 -m64 -xarch=sparc -Xc -g -mc -xs
-errfmt=error -erroff=%none -errshort=full -errtags=yes -errwarn=%none
-ftrap=%none -xbuiltin=%none -xildoff -xlibmieee -xstrconst -xcode=pic32
-xmemalign=8s -xnolibmil -xunroll=1 -xregs=no%appl -xdebugformat=dwarf
-I/usr/local/include -D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE
-D_TS_ERRNO -D_XOPEN_SOURCE='600' -H " -destination_ir=iropt -r
/var/tmp/dclarke/acomp.1574993356.16502.01.ir
/usr/include/stdio.h
        /usr/include/sys/feature_tests.h
                /usr/include/sys/ccompile.h
                /usr/include/sys/isa_defs.h
        /usr/include/iso/stdio_iso.h
                /usr/include/sys/va_list.h
                /usr/include/stdio_tag.h
                /usr/include/stdio_impl.h
        /usr/include/iso/stdio_c99.h
/dev/stdin
"/tmp/botfelk.c", line 8: error: syntax error before or at: )
c99: acomp failed for /tmp/botfelk.c
beta$ 
beta$ 

This may require a bit of a dive into the specifications however
an inline include of /dev/stdin seems wrong for some definition
of wrong. 

-- 
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
GreyBeard and suspenders optional

Reply via email to