public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100646] New: gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file
@ 2021-05-18 6:50 mtekieli+gcc at gmail dot com
2021-05-18 7:12 ` [Bug c++/100646] [11/12 Regression] " rguenth at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: mtekieli+gcc at gmail dot com @ 2021-05-18 6:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100646
Bug ID: 100646
Summary: gcc -E -fdirectives-only causes "error: unterminated
comment" when no new line at the end of file
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mtekieli+gcc at gmail dot com
Target Milestone: ---
$ cat test_gcc11.cpp
int main()
{
}
// namespace
$ g++ -E -fdirectives-only test_gcc11.cpp -o test_gcc11.o
test_gcc11.cpp:4:1: error: unterminated comment
4 | // namespace
| ^
Above error occurs when test_gcc11.cpp or anything included in test_gcc11.cpp
has a comment with no new line at the end of file.
It looks like this patch does not help:
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=b6ecd493886891f8150905a2fd3b7d54e88fc7be
It worked fine with gcc 10.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/100646] [11/12 Regression] gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file
2021-05-18 6:50 [Bug c++/100646] New: gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file mtekieli+gcc at gmail dot com
@ 2021-05-18 7:12 ` rguenth at gcc dot gnu.org
2021-05-18 7:24 ` egallager at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-18 7:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100646
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2021-05-18
Known to work| |10.3.1
Target Milestone|--- |11.2
Priority|P3 |P2
Summary|gcc -E -fdirectives-only |[11/12 Regression] gcc -E
|causes "error: unterminated |-fdirectives-only causes
|comment" when no new line |"error: unterminated
|at the end of file |comment" when no new line
| |at the end of file
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/100646] [11/12 Regression] gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file
2021-05-18 6:50 [Bug c++/100646] New: gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file mtekieli+gcc at gmail dot com
2021-05-18 7:12 ` [Bug c++/100646] [11/12 Regression] " rguenth at gcc dot gnu.org
@ 2021-05-18 7:24 ` egallager at gcc dot gnu.org
2021-05-18 7:25 ` egallager at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-05-18 7:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100646
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic, error-recovery,
| |ice-on-invalid-code
CC| |egallager at gcc dot gnu.org
--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
It took a bit of effort to get a text editor to save the file without a newline
at EOF, but once I did that, the error for me was an ICE instead of a regular
error:
100646.c:1: internal compiler error: in cpp_directive_only_process, at
libcpp/lex.c:3950
1 | int main()
|
I'll attach the full output as an attachment. This happens regardless of
whether I compile it as plain C, or C++.
(although it has been awhile since I last rebuilt GCC, so that could be the
issue...)
Here's my version and configuration info:
$ /usr/local/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/local/bin/gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin19.6.0/11.0.0/lto-wrapper
Target: x86_64-apple-darwin19.6.0
Configured with: ../configure --disable-werror --disable-werror-always
--enable-languages=all,c,c++,objc,obj-c++,lto
--enable-stage1-checking=release,rtl -C --with-system-libunwind
--enable-secureplt --enable-frame-pointer --enable-debug --without-isl
--disable-host-shared --disable-maintainer-mode --disable-default-pie
--with-ld64 --without-pic --enable-target-optspace --disable-nls
--with-system-zlib --with-libiconv-prefix=/opt/local --with-gmp=/opt/local
--with-mpfr=/opt/local --with-mpc=/opt/local --enable-lto
--with-build-config=bootstrap-debug --enable-objc-gc --enable-libada
--enable-libssp --disable-libsanitizer
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
--disable-gcov : (reconfigured) ../configure --disable-werror
--disable-werror-always --enable-languages=all,c,c++,objc,obj-c++,lto
--enable-stage1-checking=release,rtl -C --with-system-libunwind
--enable-secureplt --enable-frame-pointer --enable-debug --without-isl
--disable-host-shared --disable-maintainer-mode --disable-default-pie
--with-ld64 --without-pic --enable-target-optspace --disable-nls
--with-system-zlib --with-libiconv-prefix=/opt/local --with-gmp=/opt/local
--with-mpfr=/opt/local --with-mpc=/opt/local --enable-lto
--with-build-config=bootstrap-debug --disable-objc-gc --enable-libada
--enable-libssp --disable-libsanitizer
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
--disable-gcov
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20200920 (experimental) (GCC)
$
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/100646] [11/12 Regression] gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file
2021-05-18 6:50 [Bug c++/100646] New: gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file mtekieli+gcc at gmail dot com
2021-05-18 7:12 ` [Bug c++/100646] [11/12 Regression] " rguenth at gcc dot gnu.org
2021-05-18 7:24 ` egallager at gcc dot gnu.org
@ 2021-05-18 7:25 ` egallager at gcc dot gnu.org
2021-05-20 7:09 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-05-18 7:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100646
--- Comment #3 from Eric Gallager <egallager at gcc dot gnu.org> ---
Created attachment 50834
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50834&action=edit
terminal output from attempting to compile testcase
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/100646] [11/12 Regression] gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file
2021-05-18 6:50 [Bug c++/100646] New: gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file mtekieli+gcc at gmail dot com
` (2 preceding siblings ...)
2021-05-18 7:25 ` egallager at gcc dot gnu.org
@ 2021-05-20 7:09 ` cvs-commit at gcc dot gnu.org
2021-05-20 15:47 ` [Bug c++/100646] [11 " jakub at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-20 7:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100646
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:d15a2d261b24adcbfe5e663b15dde3df5d2b3486
commit r12-934-gd15a2d261b24adcbfe5e663b15dde3df5d2b3486
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu May 20 09:09:07 2021 +0200
libcpp: Fix up -fdirectives-only handling of // comments on last line not
terminated with newline [PR100646]
As can be seen on the testcases, before the -fdirectives-only preprocessing
rewrite the preprocessor would assume // comments are terminated by the
end of file even when newline wasn't there, but now we error out.
The following patch restores the previous behavior.
2021-05-20 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/100646
* lex.c (cpp_directive_only_process): Treat end of file as
termination
for !is_block comments.
* gcc.dg/cpp/pr100646-1.c: New test.
* gcc.dg/cpp/pr100646-2.c: New test.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/100646] [11 Regression] gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file
2021-05-18 6:50 [Bug c++/100646] New: gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file mtekieli+gcc at gmail dot com
` (3 preceding siblings ...)
2021-05-20 7:09 ` cvs-commit at gcc dot gnu.org
@ 2021-05-20 15:47 ` jakub at gcc dot gnu.org
2021-05-31 14:08 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-20 15:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100646
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
Summary|[11/12 Regression] gcc -E |[11 Regression] gcc -E
|-fdirectives-only causes |-fdirectives-only causes
|"error: unterminated |"error: unterminated
|comment" when no new line |comment" when no new line
|at the end of file |at the end of file
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/100646] [11 Regression] gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file
2021-05-18 6:50 [Bug c++/100646] New: gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file mtekieli+gcc at gmail dot com
` (4 preceding siblings ...)
2021-05-20 15:47 ` [Bug c++/100646] [11 " jakub at gcc dot gnu.org
@ 2021-05-31 14:08 ` cvs-commit at gcc dot gnu.org
2021-05-31 14:58 ` jakub at gcc dot gnu.org
2021-07-19 17:10 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-31 14:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100646
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:3a2fa2e819d4714cecf5048eda2b7e52ba9e3cdd
commit r11-8490-g3a2fa2e819d4714cecf5048eda2b7e52ba9e3cdd
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu May 20 09:09:07 2021 +0200
libcpp: Fix up -fdirectives-only handling of // comments on last line not
terminated with newline [PR100646]
As can be seen on the testcases, before the -fdirectives-only preprocessing
rewrite the preprocessor would assume // comments are terminated by the
end of file even when newline wasn't there, but now we error out.
The following patch restores the previous behavior.
2021-05-20 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/100646
* lex.c (cpp_directive_only_process): Treat end of file as
termination
for !is_block comments.
* gcc.dg/cpp/pr100646-1.c: New test.
* gcc.dg/cpp/pr100646-2.c: New test.
(cherry picked from commit d15a2d261b24adcbfe5e663b15dde3df5d2b3486)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/100646] [11 Regression] gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file
2021-05-18 6:50 [Bug c++/100646] New: gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file mtekieli+gcc at gmail dot com
` (5 preceding siblings ...)
2021-05-31 14:08 ` cvs-commit at gcc dot gnu.org
@ 2021-05-31 14:58 ` jakub at gcc dot gnu.org
2021-07-19 17:10 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-31 14:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100646
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 11.2.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/100646] [11 Regression] gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file
2021-05-18 6:50 [Bug c++/100646] New: gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file mtekieli+gcc at gmail dot com
` (6 preceding siblings ...)
2021-05-31 14:58 ` jakub at gcc dot gnu.org
@ 2021-07-19 17:10 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-07-19 17:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100646
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |boris at kolpackov dot net
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
*** Bug 101298 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-07-19 17:10 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18 6:50 [Bug c++/100646] New: gcc -E -fdirectives-only causes "error: unterminated comment" when no new line at the end of file mtekieli+gcc at gmail dot com
2021-05-18 7:12 ` [Bug c++/100646] [11/12 Regression] " rguenth at gcc dot gnu.org
2021-05-18 7:24 ` egallager at gcc dot gnu.org
2021-05-18 7:25 ` egallager at gcc dot gnu.org
2021-05-20 7:09 ` cvs-commit at gcc dot gnu.org
2021-05-20 15:47 ` [Bug c++/100646] [11 " jakub at gcc dot gnu.org
2021-05-31 14:08 ` cvs-commit at gcc dot gnu.org
2021-05-31 14:58 ` jakub at gcc dot gnu.org
2021-07-19 17:10 ` jakub at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).