https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77487
Bug ID: 77487
Summary: gcc reports "file shorter than expected" for regular
files on stdin when the offset of fd 0 isn't 0
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: pskocik at gmail dot com
Target Milestone: ---
My program calls `gcc -x c - ` with the offset of filedescriptor 0 being larger
than 0.
Consequently I get:
cc1: warning: is shorter than expected [enabled by default]
(clang reports no errors).
I think this is caused by:
libcpp/files.c:741
if (regular && total != size && STAT_SIZE_RELIABLE (file->st))
cpp_error_at (pfile, CPP_DL_WARNING, loc,
"%s is shorter than expected", file->path);
not taking the filedescriptor offset into account and that changing it to
if (regular && total != size && STAT_SIZE_RELIABLE (file->st) -
lseek(file->fd, 0, SEEK_CUR) /*should always succeed?*/ )
cpp_error_at (pfile, CPP_DL_WARNING, loc,
"%s is shorter than expected", file->path);
should fix it.
I hope I'm making sense.
Best regards,
Petr Skocik