On 22/07/24 12:24 +0300, Ovidiu Panait wrote:
Hi,
When processing large header files, the C preprocessor reports error
on the wrong line.
This mailing list is for automated emails fom our bug tracker, not for
reporting bugs. Emails sent directly to this list will not get tracked
as bugs, and will generally be ignored.
To report a bug please follow the instructions at
https://gcc.gnu.org/bugs/ - thanks.
This is 100% reproducible on my side with gcc mainline.
Reproducer:
# Build
mkdir build; cd build
../configure --host=x86_64-pc-linux-gnu --target=x86_64-wrs-linux
--enable-languages=c --disable-multilib --disable-libstdcxx-pch
--disable-libsanitizer --disable-libssp --disable-libquadmath
--disable-libquadmath-support --disable-libgomp --disable-libvtv
--disable-bootstrap
make all-host -j$(nproc)
mkdir install; make install-host DESTDIR=$(realpath ./install) -j$(nproc)
# Generate testcase
mkdir testcase; cd testcase
cat > main.c <<EOF
extern int main_begins;
extern int main_begins;
extern int main_begins;
#include "header1.h"
EOF
echo -n > header1.h
for i in {1..327676}; do
echo "extern int header1_begins;" >> header1.h
done
cat >> header1.h <<EOF
#include "header2.h"
extern int header1 ends;
EOF
echo -n > header2.h
# Test
../install/usr/local/bin/x86_64-wrs-linux-gcc main.c
In file included from main.c:4:
header1.h:327677:20: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
‘__attribute__’ before ‘ends’
327677 | #include "header2.h"
| ^
The line where the error is reported("327677") is bogus, the actual
error is on the next line("327678") in header1.h:
$ cat -n header1.h | tail -n3
327676 extern int header1_begins;
327677 #include "header2.h"
327678 extern int header1 ends;
Ovidiu