To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=49384
                  Issue #:|49384
                  Summary:|tools: warning: uninitialized variable is used
                Component:|utilities
                  Version:|680m100
                 Platform:|PC
                      URL:|
               OS/Version:|Linux
                   Status:|NEW
        Status whiteboard:|
                 Keywords:|
               Resolution:|
               Issue type:|DEFECT
                 Priority:|P3
             Subcomponent:|code
              Assigned to:|hro
              Reported by:|pmladek





------- Additional comments from [EMAIL PROTECTED] Tue May 17 05:29:09 -0700 
2005 -------
The new gcc-4.0-pre has a better detection of problems with uninitialized
variables and prints the new "warning: FOO is used uninitialized". We are going
through this warnings because there is a higher chance that the code is really
broken.

The following problem were found in the module sfx2 that is related to a haeder
file from the module tools:

/usr/src/packages/BUILD/ooo-build-1.9.100/build/src680-m100/solver/680/unxlngi6.pro/inc/vcl/lstbox.hxx:
In member function âvoid SfxDocumentTemplateDlg::Init()â:
/usr/src/packages/BUILD/ooo-build-1.9.100/build/src680-m100/:239:
warning: âaLink$pInstâ is used uninitialized in this function

The warnig is cuased by this code from sfx2/source/doc/doctdlg.cxx

                Link aLink;
                aTemplateLb.SetSelectHdl(aLink);

The method SetSelectHdl is defined in at 
solver/680/unxlngi6.pro/inc/vcl/lstbox.hxx:239 the following way:

void SetSelectHdl( const Link& rLink ) { maSelectHdl = rLink; }

The class Link is defined in tools/inc/link.hxx and has two variables:
class TOOLS_DLLPUBLIC Link
{
    void*       pInst;
    PSTUB       pFunc;
[...]

Both variables are used in the methods defined inline, for example:

inline long Link::Call(void *pCaller) const
{
    return pFunc ? (*pFunc)(pInst, pCaller) : 0;
}

Where is the problem?

The problem is that in the doctdlg.cxx is used the contructor witout parameters
of the class Link that is defined the followong way in the link.hxx:

inline Link::Link()
{
    pFunc = 0;
}

Well, the implementation is safe because pInst is accessed just only if pFunc !=
0 in all cases but the compilator is not enough smart to detect this situation.
 So, it is not a real bug. Though, I vote to fix this warning because it poits
to a real problems in many cases. There will be tendency to remove all such
warnigns in the future and if we fix it now, nobody would spend time on this
problem in the furure (and it was not so simple to investigate this particular
problem).

The fix is simple. It is enough to initialize the variable pInst in the
contructor without parameters. I'll attach a patch that fixes it.

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to