https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83063

            Bug ID: 83063
           Summary: [8 Regression] ICE on an invalid preprocessor snippet
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
  Target Milestone: ---

Starting from r254707 we do an invalid read on:

$ cat ice.cpp
#define a(...) b##__VA_OPT__ ()
a ()

$ valgrind --leak-check=yes --trace-children=yes g++ ice.cpp
==18518== Memcheck, a memory error detector
==18518== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==18518== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==18518== Command: g++ ice.cpp
==18518== 
==18520== Memcheck, a memory error detector
==18520== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==18520== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==18520== Command:
/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/8.0.0/cc1plus -quiet
-D_GNU_SOURCE ice.cpp -quiet -dumpbase ice.cpp -mtune=generic -march=x86-64
-auxbase ice -o /tmp/ccqffetG.s
==18520== 
==18520== Use of uninitialised value of size 8
==18520==    at 0x16C6D0B: paste_all_tokens (macro.c:889)
==18520==    by 0x16C6D0B: cpp_get_token_1(cpp_reader*, unsigned int*)
(macro.c:2636)
==18520==    by 0x8CE7AE: c_lex_with_flags(tree_node**, unsigned int*, unsigned
char*, int) (c-lex.c:399)
==18520==    by 0x75164E: cp_lexer_get_preprocessor_token(cp_lexer*, cp_token*)
(parser.c:793)
==18520==    by 0x792E23: cp_parser_initial_pragma (parser.c:38614)
==18520==    by 0x792E23: cp_lexer_new_main (parser.c:647)
==18520==    by 0x792E23: cp_parser_new (parser.c:3859)
==18520==    by 0x792E23: c_parse_file() (parser.c:39019)
==18520==    by 0x8DA226: c_common_parse_file() (c-opts.c:1127)
==18520==    by 0xDC0C8E: compile_file() (toplev.c:455)
==18520==    by 0x60A5E4: do_compile (toplev.c:2059)
==18520==    by 0x60A5E4: toplev::main(int, char**) (toplev.c:2194)
==18520==    by 0x60C8AA: main (main.c:39)
==18520== 
==18520== Invalid read of size 1
==18520==    at 0x16C6D0B: paste_all_tokens (macro.c:889)
==18520==    by 0x16C6D0B: cpp_get_token_1(cpp_reader*, unsigned int*)
(macro.c:2636)
==18520==    by 0x8CE7AE: c_lex_with_flags(tree_node**, unsigned int*, unsigned
char*, int) (c-lex.c:399)
==18520==    by 0x75164E: cp_lexer_get_preprocessor_token(cp_lexer*, cp_token*)
(parser.c:793)
==18520==    by 0x792E23: cp_parser_initial_pragma (parser.c:38614)
==18520==    by 0x792E23: cp_lexer_new_main (parser.c:647)
==18520==    by 0x792E23: cp_parser_new (parser.c:3859)
==18520==    by 0x792E23: c_parse_file() (parser.c:39019)
==18520==    by 0x8DA226: c_common_parse_file() (c-opts.c:1127)
==18520==    by 0xDC0C8E: compile_file() (toplev.c:455)
==18520==    by 0x60A5E4: do_compile (toplev.c:2059)
==18520==    by 0x60A5E4: toplev::main(int, char**) (toplev.c:2194)
==18520==    by 0x60C8AA: main (main.c:39)
==18520==  Address 0x4 is not stack'd, malloc'd or (recently) free'd

Reply via email to