ac16f4327f
GCC 11 ICEs on all -fdirectives-only preprocessing when the files don't end with a newline. The problem is in the assertion, for empty TUs buffer->cur == buffer->rlimit and so buffer->rlimit[-1] access triggers UB in the preprocessor, for non-empty TUs it refers to the last character in the file, which can be anything. The preprocessor adds a '\n' character (or '\r', in particular if the user file ends with '\r' then it adds another '\r' rather than '\n'), but that is added after the limit, i.e. at buffer->rlimit[0]. Now, if the routine handles occassional bumping of pos to buffer->rlimit + 1, I think it is just the assert that needs changing, usually we read from *pos if pos < limit and then e.g. if it is '\r', look at the following character (which could be one of those '\n' or '\r' at buffer->rlimit[0]). There is also the case where for '\\' before the limit we read following character and if it is '\n', do one thing, if it is '\r' read another character. But in that case if '\\' was the last char in the TU, the limit char will be '\n', so we are ok. 2021-02-03 Jakub Jelinek <jakub@redhat.com> PR preprocessor/98882 * lex.c (cpp_directive_only_process): Don't assert that rlimit[-1] is a newline, instead assert that rlimit[0] is either newline or carriage return. When seeing '\\' followed by '\r', check limit before accessing pos[1]. * gcc.dg/cpp/pr98882.c: New test. |
||
---|---|---|
c++tools | ||
config | ||
contrib | ||
fixincludes | ||
gcc | ||
gnattools | ||
gotools | ||
include | ||
INSTALL | ||
intl | ||
libada | ||
libatomic | ||
libbacktrace | ||
libcc1 | ||
libcody | ||
libcpp | ||
libdecnumber | ||
libffi | ||
libgcc | ||
libgfortran | ||
libgo | ||
libgomp | ||
libhsail-rt | ||
libiberty | ||
libitm | ||
libobjc | ||
liboffloadmic | ||
libphobos | ||
libquadmath | ||
libsanitizer | ||
libssp | ||
libstdc++-v3 | ||
libvtv | ||
lto-plugin | ||
maintainer-scripts | ||
zlib | ||
.dir-locals.el | ||
.gitattributes | ||
.gitignore | ||
ABOUT-NLS | ||
ar-lib | ||
ChangeLog | ||
ChangeLog.jit | ||
ChangeLog.tree-ssa | ||
compile | ||
config-ml.in | ||
config.guess | ||
config.rpath | ||
config.sub | ||
configure | ||
configure.ac | ||
COPYING | ||
COPYING3 | ||
COPYING3.LIB | ||
COPYING.LIB | ||
COPYING.RUNTIME | ||
depcomp | ||
install-sh | ||
libtool-ldflags | ||
libtool.m4 | ||
lt~obsolete.m4 | ||
ltgcc.m4 | ||
ltmain.sh | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
MAINTAINERS | ||
Makefile.def | ||
Makefile.in | ||
Makefile.tpl | ||
missing | ||
mkdep | ||
mkinstalldirs | ||
move-if-change | ||
multilib.am | ||
README | ||
symlink-tree | ||
test-driver | ||
ylwrap |
This directory contains the GNU Compiler Collection (GCC). The GNU Compiler Collection is free software. See the files whose names start with COPYING for copying permission. The manuals, and some of the runtime libraries, are under different terms; see the individual source files for details. The directory INSTALL contains copies of the installation information as HTML and plain text. The source of this information is gcc/doc/install.texi. The installation information includes details of what is included in the GCC sources and what files GCC installs. See the file gcc/doc/gcc.texi (together with other files that it includes) for usage and porting information. An online readable version of the manual is in the files gcc/doc/gcc.info*. See http://gcc.gnu.org/bugs/ for how to report bugs usefully. Copyright years on GCC source files may be listed using range notation, e.g., 1987-2012, indicating that every year in the range, inclusive, is a copyrightable year that could otherwise be listed individually.