gcc 2.95 used to do it almost right:
FreeBSD4:/>cpp --version
2.95.4
FreeBSD4:/>cpp < .
cpp0: Input file `' is a directory
(1) FreeBSD4:/>
LinuxDebian:~>cpp --version
cpp (GCC) 3.3.5 (Debian 1:3.3.5-8)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
LinuxDebian:~>cpp < .
cc1: stdout: No such file or directory
(1) LinuxDebian:~>
FreeBSD5:~>cpp --version
cpp (GCC) 3.4.2 [FreeBSD] 20040728
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
FreeBSD5:~>cpp < .
cc1: stdout: No such file or directory
# 1 ""
# 1 ""
cc1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See http://gcc.gnu.org/bugs.html> for instructions.
(1) FreeBSD5:~>
--
Summary: cpp segfaults on directory input
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: preprocessor
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: marcolz at stack dot nl
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-pc-freebsd5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20281