Apache OpenOffice (AOO) Bugzilla – Full Text Issue Listing |
Summary: | compiling with recent clang generates thousands of infinite-recursion warnings about DbgOut() | ||||||
---|---|---|---|---|---|---|---|
Product: | Build Tools | Reporter: | Don Lewis <truckman> | ||||
Component: | code | Assignee: | Don Lewis <truckman> | ||||
Status: | RESOLVED FIXED | QA Contact: | |||||
Severity: | Normal | ||||||
Priority: | P5 (lowest) | ||||||
Version: | 4.2.0-dev | ||||||
Target Milestone: | 4.2.0 | ||||||
Hardware: | All | ||||||
OS: | All | ||||||
Issue Type: | DEFECT | Latest Confirmation in: | --- | ||||
Developer Difficulty: | Simple | ||||||
Attachments: |
|
Created attachment 85368 [details] patch to fix DbgOut() infinite recursion warnings when compiling sal/inc/rtl/string.hxx with recent clang When compiling OpenOffice with recent versions of clang, 7735 warnings that look like this: In file included from /tmp/openoffice/aoo-4.2.0/main/sal/osl/unx/file_path_helper.cxx:36: In file included from ./file_path_helper.hxx:32: In file included from ../../inc/rtl/ustring.hxx:33: ../../inc/rtl/string.hxx:973:2: warning: all paths through this function will call itself [-Winfinite-recursion] { DbgOut( rMessage.getStr(), nOutType, pFileName, nLineNum); } ^ 1 warning generated. The problem is in this block of code in sal/inc/rtl/string.hxx: inline void DbgOut( const rtl::OString& rMessage, sal_uInt16 nOutType, const sal_Char* pFileName, sal_uInt16 nLineNum ) { DbgOut( rMessage.getStr(), nOutType, pFileName, nLineNum); } It appears to be trying to use function overloading to create a wrapper that calls a different flavor of DbgOut() that is declared in view tools/inc/tools/debug.hxx: TOOLS_DLLPUBLIC void DbgOut( const sal_Char* pMsg, sal_uInt16 nOutType = DBG_OUT_TRACE, const sal_Char* pFile = NULL, sal_uInt16 nLine = 0 ); If the compiler has not yet encountered the latter before it compiles the code in string.hxx, then it decides is must convert the char * first argument in the inner cal back to rtl::OString& and call DbgOut() recursively. In a normal build, this will always happen because the declaration in debug.hxx is conditional on the definition of the DBG_UTIL preprocessor symbol, which is undefined in normal builds. Fix the problem in this case by protecting the the declaration in string.hxx with #ifdef DBG_UTIL. Fortunately there should not be any users of the string.hxx version of DbgOut() in this case. The --enable-dbgutil configure option causes DBG_UTIL. In this case the problem will be triggered if <tools/debug.hxx> is not included before <rtl/string.hxx> and there is no guarantee of that. Fix the problem in this case by including <tools/debug.hxx> inside <rtl/string.hxx>. This requires adding a couple of directories to the include path because not all users of <rtl/string.hxx> have done so, probably because they are not using any DBG_UTIL features.