https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78324
Bug ID: 78324 Summary: Valgrind issues seen with gcc.dg/tree-ssa/builtin-sprintf-2.c Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: preprocessor Assignee: unassigned at gcc dot gnu.org Reporter: dmalcolm at gcc dot gnu.org Target Milestone: --- Seen on x86_64 with r242065. $ ./xgcc -B. -c ../../src/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c -O2 -fprintf-return-value -fdump-tree-optimized -ftrack-macro-expansion=0 -w -wrapper valgrind ==9312== Invalid read of size 1 ==9312== at 0x1AE9864: cpp_interpret_string_1(cpp_reader*, cpp_string const*, unsigned long, cpp_string*, cpp_ttype, cpp_string_location_reader*, cpp_substring_ranges*) (charset.c:1568) ==9312== by 0x1AEA07B: cpp_interpret_string_ranges(cpp_reader*, cpp_string const*, cpp_string_location_reader*, unsigned long, cpp_substring_ranges*, cpp_ttype) (charset.c:1744) ==9312== by 0x1AD73F9: get_substring_ranges_for_loc(cpp_reader*, string_concat_db*, unsigned int, cpp_ttype, cpp_substring_ranges&) (input.c:1406) ==9312== by 0x1AD74FD: get_source_location_for_substring(cpp_reader*, string_concat_db*, unsigned int, cpp_ttype, int, int, int, unsigned int*) (input.c:1449) ==9312== by 0x834BF3: c_get_substring_location(substring_loc const&, unsigned int*) (c-common.c:864) ==9312== by 0xF237A1: format_warning_va(substring_loc const&, source_range const*, char const*, int, char const*, __va_list_tag (*) [1]) (substring-locations.c:112) ==9312== by 0xF23AA7: format_warning_at_substring(substring_loc const&, source_range const*, char const*, int, char const*, ...) (substring-locations.c:179) ==9312== by 0x1997C15: (anonymous namespace)::format_directive((anonymous namespace)::pass_sprintf_length::call_info const&, (anonymous namespace)::format_result*, char const*, unsigned long, (anonymous namespace)::conversion_spec const&, tree_node*) (gimple-ssa-sprintf.c:1819) ==9312== by 0x1999135: (anonymous namespace)::pass_sprintf_length::compute_format_length((anonymous namespace)::pass_sprintf_length::call_info const&, (anonymous namespace)::format_result*) (gimple-ssa-sprintf.c:2457) ==9312== by 0x1999ECF: (anonymous namespace)::pass_sprintf_length::handle_gimple_call(gimple_stmt_iterator) (gimple-ssa-sprintf.c:2775) ==9312== by 0x1999FE3: (anonymous namespace)::pass_sprintf_length::execute(function*) (gimple-ssa-sprintf.c:2802) ==9312== by 0xDE7523: execute_one_pass(opt_pass*) (passes.c:2388) ==9312== Address 0xc9bd7e3 is 0 bytes after a block of size 3 alloc'd ==9312== at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==9312== by 0x1B33F17: xmalloc (xmalloc.c:148) ==9312== by 0x1B33FDA: xmemdup (xmemdup.c:37) ==9312== by 0x1AD7303: get_substring_ranges_for_loc(cpp_reader*, string_concat_db*, unsigned int, cpp_ttype, cpp_substring_ranges&) (input.c:1385) ==9312== by 0x1AD74FD: get_source_location_for_substring(cpp_reader*, string_concat_db*, unsigned int, cpp_ttype, int, int, int, unsigned int*) (input.c:1449) ==9312== by 0x834BF3: c_get_substring_location(substring_loc const&, unsigned int*) (c-common.c:864) ==9312== by 0xF237A1: format_warning_va(substring_loc const&, source_range const*, char const*, int, char const*, __va_list_tag (*) [1]) (substring-locations.c:112) ==9312== by 0xF23AA7: format_warning_at_substring(substring_loc const&, source_range const*, char const*, int, char const*, ...) (substring-locations.c:179) ==9312== by 0x1997C15: (anonymous namespace)::format_directive((anonymous namespace)::pass_sprintf_length::call_info const&, (anonymous namespace)::format_result*, char const*, unsigned long, (anonymous namespace)::conversion_spec const&, tree_node*) (gimple-ssa-sprintf.c:1819) ==9312== by 0x1999135: (anonymous namespace)::pass_sprintf_length::compute_format_length((anonymous namespace)::pass_sprintf_length::call_info const&, (anonymous namespace)::format_result*) (gimple-ssa-sprintf.c:2457) ==9312== by 0x1999ECF: (anonymous namespace)::pass_sprintf_length::handle_gimple_call(gimple_stmt_iterator) (gimple-ssa-sprintf.c:2775) ==9312== by 0x1999FE3: (anonymous namespace)::pass_sprintf_length::execute(function*) (gimple-ssa-sprintf.c:2802) ==9312== ==9312== Conditional jump or move depends on uninitialised value(s) ==9312== at 0x1AE9867: cpp_interpret_string_1(cpp_reader*, cpp_string const*, unsigned long, cpp_string*, cpp_ttype, cpp_string_location_reader*, cpp_substring_ranges*) (charset.c:1568) ==9312== by 0x1AEA07B: cpp_interpret_string_ranges(cpp_reader*, cpp_string const*, cpp_string_location_reader*, unsigned long, cpp_substring_ranges*, cpp_ttype) (charset.c:1744) ==9312== by 0x1AD73F9: get_substring_ranges_for_loc(cpp_reader*, string_concat_db*, unsigned int, cpp_ttype, cpp_substring_ranges&) (input.c:1406) ==9312== by 0x1AD74FD: get_source_location_for_substring(cpp_reader*, string_concat_db*, unsigned int, cpp_ttype, int, int, int, unsigned int*) (input.c:1449) ==9312== by 0x834BF3: c_get_substring_location(substring_loc const&, unsigned int*) (c-common.c:864) ==9312== by 0xF237A1: format_warning_va(substring_loc const&, source_range const*, char const*, int, char const*, __va_list_tag (*) [1]) (substring-locations.c:112) ==9312== by 0xF23AA7: format_warning_at_substring(substring_loc const&, source_range const*, char const*, int, char const*, ...) (substring-locations.c:179) ==9312== by 0x1997C15: (anonymous namespace)::format_directive((anonymous namespace)::pass_sprintf_length::call_info const&, (anonymous namespace)::format_result*, char const*, unsigned long, (anonymous namespace)::conversion_spec const&, tree_node*) (gimple-ssa-sprintf.c:1819) ==9312== by 0x1999135: (anonymous namespace)::pass_sprintf_length::compute_format_length((anonymous namespace)::pass_sprintf_length::call_info const&, (anonymous namespace)::format_result*) (gimple-ssa-sprintf.c:2457) ==9312== by 0x1999ECF: (anonymous namespace)::pass_sprintf_length::handle_gimple_call(gimple_stmt_iterator) (gimple-ssa-sprintf.c:2775) ==9312== by 0x1999FE3: (anonymous namespace)::pass_sprintf_length::execute(function*) (gimple-ssa-sprintf.c:2802) ==9312== by 0xDE7523: execute_one_pass(opt_pass*) (passes.c:2388)