[Bug preprocessor/78498] New: valgrind conditional jump or move depends on uninitialised value(s) in format_type_warning

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Nov 23 19:21:00 GMT 2016


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

            Bug ID: 78498
           Summary: valgrind conditional jump or move depends on
                    uninitialised value(s) in format_type_warning
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

While debugging some memory problems in my own work I came across a Valgrind
error that looks like it might be related to or a vestige of bug 78324.

$ cat a.c && gcc -O2 -S -Wall -Wextra a.c -wrapper valgrind
void f (void)
{
  __builtin_printf ("%i", "");
}

==28974== Memcheck, a memory error detector
==28974== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==28974== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==28974== Command: /build/gcc-svn/gcc/cc1 -quiet -iprefix
/home/msebor/build/gcc-svn/gcc/../lib/gcc/x86_64-pc-linux-gnu/7.0.0/ -isystem
/build/gcc-svn/gcc/include -isystem /build/gcc-svn/gcc/include-fixed a.c -quiet
-dumpbase a.c -mtune=generic -march=x86-64 -auxbase a -O2 -Wall -Wextra -o a.s
==28974== 
==28974== Conditional jump or move depends on uninitialised value(s)
==28974==    at 0x4C2CC18: strlen (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==28974==    by 0x1A6F646: xstrndup (xstrndup.c:51)
==28974==    by 0x88D4F5: get_corrected_substring(substring_loc const&,
format_wanted_type*, tree_node*, format_kind_info const*, int, char)
(c-format.c:3350)
==28974==    by 0x88D886: format_type_warning(substring_loc const&,
source_range*, format_wanted_type*, tree_node*, tree_node*, format_kind_info
const*, int, char) (c-format.c:3461)
==28974==    by 0x88CCEE: check_format_types(substring_loc const&,
format_wanted_type*, format_kind_info const*, int, char) (c-format.c:3075)
==28974==    by 0x88BE99: argument_parser::check_argument_type(format_char_info
const*, length_modifier const&, tree_node*&, char const*&, bool, unsigned
long&, tree_node*&, int, char const*, char const*, unsigned int, char)
(c-format.c:2675)
==28974==    by 0x88C30F: check_format_info_main(format_check_results*,
function_format_info*, char const*, unsigned int, tree_node*, int, tree_node*,
unsigned long, object_allocator<format_wanted_type>&) (c-format.c:2820)
==28974==    by 0x889674: check_format_arg(void*, tree_node*, unsigned long)
(c-format.c:1672)
==28974==    by 0x87616C: check_function_arguments_recurse(void (*)(void*,
tree_node*, unsigned long), void*, tree_node*, unsigned long) (c-common.c:5689)
==28974==    by 0x875EB5: check_function_arguments_recurse(void (*)(void*,
tree_node*, unsigned long), void*, tree_node*, unsigned long) (c-common.c:5622)
==28974==    by 0x888671: check_format_info(function_format_info*, tree_node*)
(c-format.c:1405)
==28974==    by 0x88795E: check_function_format(tree_node*, int, tree_node**)
(c-format.c:1066)
==28974== 
a.c: In function ‘f’:
a.c:3:23: warning: format ‘%i’ expects argument of type ‘int’, but argument 2
has type ‘char *’ [-Wformat=]
   __builtin_printf ("%i", "");
                      ~^   ~~
                      %s
==28974== 
==28974== HEAP SUMMARY:
==28974==     in use at exit: 2,437,618 bytes in 2,544 blocks
==28974==   total heap usage: 12,675 allocs, 10,131 frees, 5,117,261 bytes
allocated
==28974== 
==28974== LEAK SUMMARY:
==28974==    definitely lost: 0 bytes in 0 blocks
==28974==    indirectly lost: 0 bytes in 0 blocks
==28974==      possibly lost: 0 bytes in 0 blocks
==28974==    still reachable: 2,437,618 bytes in 2,544 blocks
==28974==         suppressed: 0 bytes in 0 blocks
==28974== Rerun with --leak-check=full to see details of leaked memory
==28974== 
==28974== For counts of detected and suppressed errors, rerun with: -v
==28974== Use --track-origins=yes to see where uninitialised values come from
==28974== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)


More information about the Gcc-bugs mailing list