我如何解释此错误,堆摘要,统一变量?

问题描述 投票:0回答:2
#include <bits/stdc++.h>
int main(){
    int a, b = 10, r;
    printf("%d\n", a);
}

> ==13235== Memcheck, a memory error detector
> ==13235== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
> ==13235== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
> ==13235== Command: ./assign
> ==13235==
> ==13235== error calling PR_SET_PTRACER, vgdb might block
> ==13235== Conditional jump or move depends on uninitialised value(s)
> ==13235==    at 0x4AAEAD8: __vfprintf_internal (vfprintf-internal.c:1687)
> ==13235==    by 0x4A98EBE: printf (printf.c:33)
> ==13235==    by 0x1091B1: main (assignment.cpp:5)
> ==13235==
> ==13235== Use of uninitialised value of size 8
> ==13235==    at 0x4A9281B: _itoa_word (_itoa.c:179)
> ==13235==    by 0x4AAE6F4: __vfprintf_internal (vfprintf-internal.c:1687)
> ==13235==    by 0x4A98EBE: printf (printf.c:33)
> ==13235==    by 0x1091B1: main (assignment.cpp:5)
> ==13235==
> ==13235== Conditional jump or move depends on uninitialised value(s)
> ==13235==    at 0x4A9282D: _itoa_word (_itoa.c:179)
> ==13235==    by 0x4AAE6F4: __vfprintf_internal (vfprintf-internal.c:1687)
> ==13235==    by 0x4A98EBE: printf (printf.c:33)
> ==13235==    by 0x1091B1: main (assignment.cpp:5)
> ==13235==
> ==13235== Conditional jump or move depends on uninitialised value(s)
> ==13235==    at 0x4AAF3A8: __vfprintf_internal (vfprintf-internal.c:1687)
> ==13235==    by 0x4A98EBE: printf (printf.c:33)
> ==13235==    by 0x1091B1: main (assignment.cpp:5)
> ==13235==
> ==13235== Conditional jump or move depends on uninitialised value(s)
> ==13235==    at 0x4AAE86E: __vfprintf_internal (vfprintf-internal.c:1687)
> ==13235==    by 0x4A98EBE: printf (printf.c:33)
> ==13235==    by 0x1091B1: main (assignment.cpp:5)
> ==13235== 0
> ==13235==
> ==13235== HEAP SUMMARY:
> ==13235==     in use at exit: 0 bytes in 0 blocks
> ==13235==   total heap usage: 2 allocs, 2 frees, 73,216 bytes allocated
> ==13235==
> ==13235== All heap blocks were freed -- no leaks are possible
> ==13235==
> ==13235== Use --track-origins=yes to see where uninitialised values come from
> ==13235== For lists of detected and suppressed errors, rerun with: -s
> ==13235== ERROR SUMMARY: 5 errors from 5 contexts (suppressed: 0 from 0)

我无法从此输入中出错,堆摘要显示什么,为什么未初始化变量的大小为8?另外,“总堆使用量:2个分配,2个空闲,分配的73,216个字节”是什么意思?

#include int main(){int a,b = 10,r; printf(“%d \ n”,a); }> == 13235 == Memcheck,一个内存错误检测器> == 13235 ==版权所有(C)2002-2017,并通过...

c++ c debugging g++ valgrind
2个回答
0
投票

未初始化的变量错误来自此行:


0
投票

来自valgrind的第一条消息指出“有条件的跳转或移动取决于未初始化的值”,并在代码中引用此行:

© www.soinside.com 2019 - 2024. All rights reserved.