| Summary: | valgrind shows "Conditional jump or move depends on uninitialised value" on valid code | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | rafal.lists | ||||
| Component: | glibc | Assignee: | Andreas Schwab <schwab> | ||||
| Status: | CLOSED NOTABUG | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||
| Severity: | unspecified | Docs Contact: | |||||
| Priority: | unspecified | ||||||
| Version: | 14 | CC: | fweimer, jakub, schwab | ||||
| Target Milestone: | --- | ||||||
| Target Release: | --- | ||||||
| Hardware: | i386 | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | Doc Type: | Bug Fix | |||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2011-06-03 13:59:55 UTC | Type: | --- | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Attachments: |
|
||||||
Initialize it then. |
Created attachment 502542 [details] Code to compile Description of problem: When running following code: #include <locale> int main(int argc, char *argv[]) { std::wstring wide(L"ala"); std::locale locale; std::mbstate_t mystate; const std::codecvt<wchar_t, char, std::mbstate_t>& facet = std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >( locale ); std::codecvt<wchar_t,char, std::mbstate_t>::result myresult; size_t length = 1000; char* buffer = new char[length]; const wchar_t* pwc; char* pc; // translate characters: myresult = facet.out (mystate, wide.c_str(), wide.c_str()+ wide.size(), pwc, buffer, buffer + length, pc); delete [] buffer; if ( myresult == std::codecvt<wchar_t,char,mbstate_t>::ok ) return 0; else return 1; } I receive following output from valgrind: ==31825== Memcheck, a memory error detector ==31825== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al. ==31825== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info ==31825== Command: ./AAA ==31825== ==31825== Conditional jump or move depends on uninitialised value(s) ==31825== at 0xB14D83: __gconv_transform_internal_ascii (in /lib/libc-2.13.so) ==31825== by 0xB7A604: wcsnrtombs (in /lib/libc-2.13.so) ==31825== by 0x5A8D446: std::codecvt<wchar_t, char, __mbstate_t>::do_out(__mbstate_t&, wchar_t const*, wchar_t const*, wchar_t const*&, char*, char*, char*&) const (in /usr/lib/libstdc++.so.6.0.14) ==31825== by 0x8048988: std::__codecvt_abstract_base<wchar_t, char, __mbstate_t>::out(__mbstate_t&, wchar_t const*, wchar_t const*, wchar_t const*&, char*, char*, char*&) const (in /home/rafal/workspace/AAA/AAA) ==31825== by 0x80488B6: main (in /home/rafal/workspace/AAA/AAA) ==31825== Uninitialised value was created by a stack allocation ==31825== at 0x80487DC: main (in /home/rafal/workspace/AAA/AAA) ==31825== ==31825== ==31825== HEAP SUMMARY: ==31825== in use at exit: 0 bytes in 0 blocks ==31825== total heap usage: 2 allocs, 2 frees, 1,028 bytes allocated ==31825== ==31825== All heap blocks were freed -- no leaks are possible ==31825== ==31825== For counts of detected and suppressed errors, rerun with: -v ==31825== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 15 from 8) When I use this code in some larger application it crashes. Version-Release number of selected component (if applicable): libc 2.13 gcc version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC) How reproducible: Steps to Reproduce: 1.g++ main.cpp -o AAA 2.valgrind ./AAA 3.