|
From: Jonathan M. <jma...@us...> - 2008-01-08 06:01:44
|
Hi all, After running valgrind on XBMC for Linux, we've hit a strange issue with an assignment to a bool. To simplify, the code is of the form: bool done(test > 3); It is my understanding (and this may well be what is in error ;) that this is essentially the same (ref http://www.cplusplus.com/doc/tutorial/variables.html) as: bool done = (test > 3); However, code in the first form causes valgrind to declare that usage of the variable done is use of an uninitialised variable, whereas code in the second form yields no complaints. The real code in question is the following: 34 bool needsToScroll(m_renderRect.Width() + 0.5f < m_textWidth); // 0.5f to deal with floating point rounding issues 35 if (m_scrolling && needsToScroll) 36 m_textLayout.RenderScrolling(m_renderRect.x1, m_renderRect.y1, m_label.angle, color, m_label.shadowColor, 0, m_renderRect.Width(), m_scrollInfo); 37 else 38 { 39 float posX = m_renderRect.x1; 40 DWORD align = 0; 41 if (!needsToScroll) 42 { // hack for right and centered multiline text, as GUITextLayout::Render() treats posX as the right hand 43 // or center edge of the text (see GUIFontTTF::DrawTextInternal), and this has already been taken care of 44 // in SetLabel(), but we wish to still pass the horizontal alignment info through (so that multiline text 45 // is aligned correctly), so we must undo the SetLabel() changes for horizontal alignment. 46 if (m_label.align & XBFONT_RIGHT) 47 posX += m_renderRect.Width(); 48 else if (m_label.align & XBFONT_CENTER_X) 49 posX += m_renderRect.Width() * 0.5f; 50 align = m_label.align & ~XBFONT_CENTER_Y; // ignore vertical alignment 51 } 52 m_textLayout.Render(posX, m_renderRect.y1, m_label.angle, color, m_label.shadowColor, align, m_renderRect.Width()); 53 } (note that m_scrolling is assigned in the constructor, so the needsToScroll variable is clearly the issue) and the output from valgrind relevant to this is: ==23316== Conditional jump or move depends on uninitialised value(s) ==23316== at 0x85D0CD9: CGUIListLabel::Render() (GUIListLabel.cpp:35) ==23316== by 0x85A8420: CGUIControl::DoRender(unsigned long) (GUIControl.cpp:115) ==23316== by 0x85CB4E9: CGUIListItemLayout::Render(CGUIListItem*, unsigned long, unsigned long) (GUIListItemLayout.cpp:144) ==23316== by 0x8595513: CGUIBaseContainer::RenderItem(float, float, CGUIListItem*, bool) (GUIBaseContainer.cpp:64) ==23316== by 0x85C5892: CGUIListContainer::Render() (GUIListContainer.cpp:89) ==23316== by 0x85A8420: CGUIControl::DoRender(unsigned long) (GUIControl.cpp:115) ==23316== by 0x859435D: CGUIBaseContainer::DoRender(unsigned long) (GUIBaseContainer.cpp:392) ==23316== by 0x85FBB8A: CGUIWindow::Render() (GUIWindow.cpp:456) ==23316== by 0x8600464: CGUIWindowManager::Render_Internal() (GUIWindowManager.cpp:409) ==23316== by 0x860169D: CGUIWindowManager::Render() (GUIWindowManager.cpp:402) ==23316== by 0x83147EE: CApplication::DoRender() (Application.cpp:2491) ==23316== by 0x8328C1D: CApplicationRenderer::Render(bool) (ApplicationRenderer.cpp:322) ==23316== ==23316== Conditional jump or move depends on uninitialised value(s) ==23316== at 0x85D0D85: CGUIListLabel::Render() (GUIListLabel.cpp:41) ==23316== by 0x85A8420: CGUIControl::DoRender(unsigned long) (GUIControl.cpp:115) ==23316== by 0x85CB4E9: CGUIListItemLayout::Render(CGUIListItem*, unsigned long, unsigned long) (GUIListItemLayout.cpp:144) ==23316== by 0x8595513: CGUIBaseContainer::RenderItem(float, float, CGUIListItem*, bool) (GUIBaseContainer.cpp:64) ==23316== by 0x85C5892: CGUIListContainer::Render() (GUIListContainer.cpp:89) ==23316== by 0x85A8420: CGUIControl::DoRender(unsigned long) (GUIControl.cpp:115) ==23316== by 0x859435D: CGUIBaseContainer::DoRender(unsigned long) (GUIBaseContainer.cpp:392) ==23316== by 0x85FBB8A: CGUIWindow::Render() (GUIWindow.cpp:456) ==23316== by 0x8600464: CGUIWindowManager::Render_Internal() (GUIWindowManager.cpp:409) ==23316== by 0x860169D: CGUIWindowManager::Render() (GUIWindowManager.cpp:402) ==23316== by 0x83147EE: CApplication::DoRender() (Application.cpp:2491) ==23316== by 0x8328C1D: CApplicationRenderer::Render(bool) (ApplicationRenderer.cpp:322) Your assessment of the issue would be greatly appreciated :) Cheers, Jonathan |