An -fsanitize=undefined instrumented compiler shows: cp/parser.c:768:7: runtime error: member call on null pointer of type 'struct vec'
760 static inline cp_token * 761 cp_lexer_previous_token (cp_lexer *lexer) 762 { 763 cp_token_position tp = cp_lexer_previous_token_position (lexer); 764 765 /* Skip past purged tokens. */ 766 while (tp->purged_p) 767 { 768 gcc_assert (tp != lexer->buffer->address ()); 769 tp--; 770 } 771 772 return cp_lexer_token_at (lexer, tp); 773 } (gdb) p *lexer $1 = { buffer = 0x0, last_token = 0x7ffff7e0c2f8, next_token = 0x7ffff7e0c298, saved_tokens = { m_vec = 0x92c6b20 }, next = 0x7ffff5f96480, debugging_p = false, in_pragma = false } Fixed by guarding against the invalid member call on a null pointer. Tested on ppc64le. Ok for trunk? Thanks. PR c++/71182 * parser.c (cp_lexer_previous_token): Guard against member call on null pointer. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 08f5f9e52ef2..f430af97fdf1 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -765,7 +765,7 @@ cp_lexer_previous_token (cp_lexer *lexer) /* Skip past purged tokens. */ while (tp->purged_p) { - gcc_assert (tp != lexer->buffer->address ()); + gcc_assert (!lexer->buffer || tp != lexer->buffer->address ()); tp--; } -- Markus