https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112956
Bug ID: 112956 Summary: Valgrind errors on pr88974.c Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- With valgrind checking I'm seeing: /home/jakub/src/gcc/obj88/gcc/xgcc -B/home/jakub/src/gcc/obj88/gcc/ /home/jakub/src/gcc/gcc/testsuite/c-c++-common/cpp/pr88974.c -fdiagnostics-plain-output -Wc++ -compat -E -o pr88974.i /home/jakub/src/gcc/gcc/testsuite/c-c++-common/cpp/pr88974.c:4:31: error: missing terminating > character /home/jakub/src/gcc/gcc/testsuite/c-c++-common/cpp/pr88974.c:4:31: error: missing ')' after "__has_include" operand ==600549== Conditional jump or move depends on uninitialised value(s) ==600549== at 0x1DD3A05: cpp_get_token_1(cpp_reader*, unsigned int*) (macro.cc:3050) ==600549== by 0x1DBFC7F: _cpp_parse_expr (expr.cc:1392) ==600549== by 0x1DB9471: do_if(cpp_reader*) (directives.cc:2087) ==600549== by 0x1DBB4D8: _cpp_handle_directive (directives.cc:572) ==600549== by 0x1DCD488: _cpp_lex_token (lex.cc:3682) ==600549== by 0x1DD3A97: cpp_get_token_1(cpp_reader*, unsigned int*) (macro.cc:2936) ==600549== by 0x7F7EE4: scan_translation_unit (c-ppoutput.cc:350) ==600549== by 0x7F7EE4: preprocess_file(cpp_reader*) (c-ppoutput.cc:106) ==600549== by 0x7F6235: c_common_init() (c-opts.cc:1280) ==600549== by 0x704C8B: lang_dependent_init (toplev.cc:1837) ==600549== by 0x704C8B: do_compile (toplev.cc:2135) ==600549== by 0x704C8B: toplev::main(int, char**) (toplev.cc:2306) ==600549== by 0x7064BA: main (main.cc:39) --- libcpp/lex.cc.jj 2023-12-01 08:10:44.686296604 +0100 +++ libcpp/lex.cc 2023-12-11 10:58:08.907527616 +0100 @@ -3833,6 +3833,7 @@ _cpp_lex_direct (cpp_reader *pfile) pfile->state.in_deferred_pragma = false; if (!pfile->state.pragma_allow_expansion) pfile->state.prevent_expansion--; + result->src_loc = 0; return result; } if (!_cpp_get_fresh_line (pfile)) @@ -3849,6 +3850,8 @@ _cpp_lex_direct (cpp_reader *pfile) /* Now pop the buffer that _cpp_get_fresh_line did not. */ _cpp_pop_buffer (pfile); } + else + result->src_loc = 0; return result; } if (buffer != pfile->buffer) or even just the second hunk of it fixes this (but otherwise untested so far).