public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/103415] New: [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739
@ 2021-11-24 17:48 gscfq@t-online.de
2021-11-24 17:49 ` [Bug c/103415] " gscfq@t-online.de
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: gscfq@t-online.de @ 2021-11-24 17:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103415
Bug ID: 103415
Summary: [12 Regression] ICE in cpp_interpret_string_1, at
libcpp/charset.c:1739
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: gscfq@t-online.de
Target Milestone: ---
Started between 20210808 and 20210822 :
$ cat z1.c
#define n(x...) = #__VA_OPT__(x##1)
const char *c n(1, 2);
$ gcc-12-20211121 -c z1.c
z1.c:1:20: warning: __VA_OPT__ can only appear in the expansion of a C++20
variadic macro
1 | #define n(x...) = #__VA_OPT__(x##1)
| ^
z1.c:2:1: internal compiler error: in cpp_interpret_string_1, at
libcpp/charset.c:1739
2 | const char *c n(1, 2);
| ^~~~~
0x18b9877 cpp_interpret_string_1
../../libcpp/charset.c:1739
0x18b9aed cpp_interpret_string(cpp_reader*, cpp_string const*, unsigned long,
cpp_string*, cpp_ttype)
../../libcpp/charset.c:1819
0x78aad3 c_parser_string_literal(c_parser*, bool, bool)
../../gcc/c/c-parser.c:7410
0x78b528 c_parser_postfix_expression
../../gcc/c/c-parser.c:9023
0x795b12 c_parser_unary_expression
../../gcc/c/c-parser.c:8255
0x796b5f c_parser_cast_expression
../../gcc/c/c-parser.c:8097
0x796e19 c_parser_binary_expression
../../gcc/c/c-parser.c:7900
0x79800b c_parser_conditional_expression
../../gcc/c/c-parser.c:7600
0x7986d1 c_parser_expr_no_commas
../../gcc/c/c-parser.c:7515
0x79eaf9 c_parser_initializer
../../gcc/c/c-parser.c:5212
0x7aef2a c_parser_declaration_or_fndef
../../gcc/c/c-parser.c:2282
0x7b70cf c_parser_external_declaration
../../gcc/c/c-parser.c:1780
0x7b79fb c_parser_translation_unit
../../gcc/c/c-parser.c:1653
0x7b79fb c_parse_file()
../../gcc/c/c-parser.c:23280
0x808eb2 c_common_parse_file()
../../gcc/c-family/c-opts.c:1240
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/103415] [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739
2021-11-24 17:48 [Bug c/103415] New: [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739 gscfq@t-online.de
@ 2021-11-24 17:49 ` gscfq@t-online.de
2021-11-24 17:51 ` [Bug preprocessor/103415] " pinskia at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: gscfq@t-online.de @ 2021-11-24 17:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103415
G. Steinmetz <gscfq@t-online.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-invalid-code
--- Comment #1 from G. Steinmetz <gscfq@t-online.de> ---
Probably related :
$ cat z2.c
#define n(x...) #__VA_OPT__(x##__VA_ARGS__##c)
const char *c n(1)
$ cat z3.c
#define n(x...) = #__VA_OPT__(x##__VA_ARGS__##c)
const char *c n(1);
$ gcc-12-20211121 -c z2.c
z2.c:1:18: warning: __VA_OPT__ can only appear in the expansion of a C++20
variadic macro
1 | #define n(x...) #__VA_OPT__(x##__VA_ARGS__##c)
| ^
z2.c:1:32: warning: __VA_ARGS__ can only appear in the expansion of a C99
variadic macro
1 | #define n(x...) #__VA_OPT__(x##__VA_ARGS__##c)
| ^
z2.c:2:1: internal compiler error: Segmentation fault
2 | const char *c n(1)
| ^~~~~
0xcb463f crash_signal
../../gcc/toplev.c:322
0x18d0cca new_string_token
../../libcpp/macro.c:472
0x18d0cca stringify_arg
../../libcpp/macro.c:941
0x18d32e3 replace_args
../../libcpp/macro.c:2068
0x18d32e3 enter_macro_context
../../libcpp/macro.c:1496
0x18d3750 cpp_get_token_1
../../libcpp/macro.c:2986
0x7ff27d c_lex_with_flags(tree_node**, unsigned int*, unsigned char*, int)
../../gcc/c-family/c-lex.c:483
0x78743f c_lex_one_token
../../gcc/c/c-parser.c:279
0x788414 c_parser_peek_nth_token(c_parser*, unsigned int)
../../gcc/c/c-parser.c:517
0x7889a0 c_parser_nth_token_starts_std_attributes
../../gcc/c/c-parser.c:5092
0x79524b c_parser_direct_declarator
../../gcc/c/c-parser.c:3951
0x79524b c_parser_declarator(c_parser*, bool, c_dtr_syn, bool*)
../../gcc/c/c-parser.c:3894
0x795033 c_parser_declarator(c_parser*, bool, c_dtr_syn, bool*)
../../gcc/c/c-parser.c:3886
0x7ae573 c_parser_declaration_or_fndef
../../gcc/c/c-parser.c:2154
0x7b70cf c_parser_external_declaration
../../gcc/c/c-parser.c:1780
0x7b79fb c_parser_translation_unit
../../gcc/c/c-parser.c:1653
0x7b79fb c_parse_file()
../../gcc/c/c-parser.c:23280
0x808eb2 c_common_parse_file()
../../gcc/c-family/c-opts.c:1240
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug preprocessor/103415] [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739
2021-11-24 17:48 [Bug c/103415] New: [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739 gscfq@t-online.de
2021-11-24 17:49 ` [Bug c/103415] " gscfq@t-online.de
@ 2021-11-24 17:51 ` pinskia at gcc dot gnu.org
2021-11-25 0:33 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-24 17:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103415
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug preprocessor/103415] [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739
2021-11-24 17:48 [Bug c/103415] New: [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739 gscfq@t-online.de
2021-11-24 17:49 ` [Bug c/103415] " gscfq@t-online.de
2021-11-24 17:51 ` [Bug preprocessor/103415] " pinskia at gcc dot gnu.org
@ 2021-11-25 0:33 ` pinskia at gcc dot gnu.org
2021-11-25 9:58 ` marxin at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-25 0:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103415
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2021-11-25
Status|UNCONFIRMED |NEW
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
(In reply to G. Steinmetz from comment #0)
> Started between 20210808 and 20210822 :
Then it is when __VA_OPT__ support was added in r12-2940-gd56599979211266b.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug preprocessor/103415] [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739
2021-11-24 17:48 [Bug c/103415] New: [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739 gscfq@t-online.de
` (2 preceding siblings ...)
2021-11-25 0:33 ` pinskia at gcc dot gnu.org
@ 2021-11-25 9:58 ` marxin at gcc dot gnu.org
2021-11-25 15:25 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-25 9:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103415
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |marxin at gcc dot gnu.org
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> Confirmed.
>
>
> (In reply to G. Steinmetz from comment #0)
> > Started between 20210808 and 20210822 :
>
> Then it is when __VA_OPT__ support was added in r12-2940-gd56599979211266b.
Yes, it started with the revision.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug preprocessor/103415] [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739
2021-11-24 17:48 [Bug c/103415] New: [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739 gscfq@t-online.de
` (3 preceding siblings ...)
2021-11-25 9:58 ` marxin at gcc dot gnu.org
@ 2021-11-25 15:25 ` jakub at gcc dot gnu.org
2021-11-25 17:11 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-11-25 15:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103415
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
__VA_OPT__ has been supported for a few more years, my change just added
support for stringification of __VA_OPT__...
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug preprocessor/103415] [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739
2021-11-24 17:48 [Bug c/103415] New: [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739 gscfq@t-online.de
` (4 preceding siblings ...)
2021-11-25 15:25 ` jakub at gcc dot gnu.org
@ 2021-11-25 17:11 ` jakub at gcc dot gnu.org
2021-12-01 9:10 ` cvs-commit at gcc dot gnu.org
2021-12-01 9:16 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-11-25 17:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103415
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 51873
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51873&action=edit
gcc12-pr103415.patch
Untested fix.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug preprocessor/103415] [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739
2021-11-24 17:48 [Bug c/103415] New: [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739 gscfq@t-online.de
` (5 preceding siblings ...)
2021-11-25 17:11 ` jakub at gcc dot gnu.org
@ 2021-12-01 9:10 ` cvs-commit at gcc dot gnu.org
2021-12-01 9:16 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-01 9:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103415
--- Comment #6 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:ac5fd364f0978c62ae759e7b36ce6b912a27546c
commit r12-5651-gac5fd364f0978c62ae759e7b36ce6b912a27546c
Author: Jakub Jelinek <jakub@redhat.com>
Date: Wed Dec 1 10:07:59 2021 +0100
libcpp: Fix up #__VA_OPT__ handling [PR103415]
stringify_arg uses pfile->u_buff to create the string literal.
Unfortunately, paste_tokens -> _cpp_lex_direct -> lex_number ->
_cpp_unaligned_alloc
can in some cases use pfile->u_buff too, which results in losing everything
prepared for the string literal until the token pasting.
The following patch fixes that by not calling paste_token during the
construction of the string literal, but doing that before. All the tokens
we are processing have been pushed into a token buffer using
tokens_buff_add_token so it is fine if we paste some of them in that buffer
(successful pasting creates a new token in that buffer), move following
tokens if any to make it contiguous, pop (throw away) the extra tokens at
the end and then do stringify_arg.
Also, paste_tokens now copies over PREV_WHITE and PREV_FALLTHROUGH flags
from the original lhs token to the replacement token. Copying that way
the PREV_WHITE flag is needed for the #__VA_OPT__ handling and copying
over PREV_FALLTHROUGH fixes the new Wimplicit-fallthrough-38.c test.
2021-12-01 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/103415
libcpp/
* macro.c (stringify_arg): Remove va_opt argument and va_opt
handling.
(paste_tokens): On successful paste or in PREV_WHITE and
PREV_FALLTHROUGH flags from the *plhs token to the new token.
(replace_args): Adjust stringify_arg callers. For #__VA_OPT__,
perform token pasting in a separate loop before stringify_arg call.
gcc/testsuite/
* c-c++-common/cpp/va-opt-8.c: New test.
* c-c++-common/Wimplicit-fallthrough-38.c: New test.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug preprocessor/103415] [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739
2021-11-24 17:48 [Bug c/103415] New: [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739 gscfq@t-online.de
` (6 preceding siblings ...)
2021-12-01 9:10 ` cvs-commit at gcc dot gnu.org
@ 2021-12-01 9:16 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-12-01 9:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103415
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-12-01 9:16 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24 17:48 [Bug c/103415] New: [12 Regression] ICE in cpp_interpret_string_1, at libcpp/charset.c:1739 gscfq@t-online.de
2021-11-24 17:49 ` [Bug c/103415] " gscfq@t-online.de
2021-11-24 17:51 ` [Bug preprocessor/103415] " pinskia at gcc dot gnu.org
2021-11-25 0:33 ` pinskia at gcc dot gnu.org
2021-11-25 9:58 ` marxin at gcc dot gnu.org
2021-11-25 15:25 ` jakub at gcc dot gnu.org
2021-11-25 17:11 ` jakub at gcc dot gnu.org
2021-12-01 9:10 ` cvs-commit at gcc dot gnu.org
2021-12-01 9:16 ` 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).