You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Lukas Grützmacher (JIRA)" <xe...@xml.apache.org> on 2006/05/11 15:53:04 UTC

[jira] Created: (XERCESC-1593) critical Warning on compiling XercesC 2.7.0

critical Warning on compiling XercesC 2.7.0
-------------------------------------------

         Key: XERCESC-1593
         URL: http://issues.apache.org/jira/browse/XERCESC-1593
     Project: Xerces-C++
        Type: Bug

  Components: Build  
    Versions: 2.7.0    
 Environment: MSVC 2003 (7.1)
Set Warning Level to 4
    Reporter: Lukas Grützmacher


I've compiled XercesC 2.7.0 from sources with MSVC2003.
I've changed the project settings to use always warning level 4.

Thereby I found a lot of warnings. IMHO some of them are critical:

xerces-c-src_2_7_0\src\xercesc\validators\schema\traverseschema.cpp(6490) : warning C4701: local variable 'defAttType' may be used without having been initialized

xerces-c-src_2_7_0\src\xercesc\util\regx\token.cpp(259) : warning C4701: local variable 'ret2' may be used without having been initialized

xerces-c-src_2_7_0\src\xercesc\util\regx\RegularExpression.cpp(184) : warning C4244: 'argument' : conversion from 'XMLInt32' to 'const XMLCh', possible loss of data

xerces-c-src_2_7_0\src\xercesc\util\platforms\win32\win32platformutils.cpp(795) : warning C4701: local variable 'retVal' may be used without having been initialized

xerces-c-src_2_7_0\tests\xserializertest\xserializertest.cpp(537) : warning C4701: local variable 'duration' may be used without having been initialized

Many others are not critical but sould be fixed, too. Here are some examples:

DFAContentModel.cpp
..\..\..\..\..\src\xercesc\validators\common\CMNode.hpp(129) : warning C4245: 'initializing' : conversion from 'int' to 'unsigned int', signed/unsigned mismatch

xerces-c-src_2_7_0\src\xercesc\internal\XSAXMLScanner.cpp(310) : warning C4245: 'argument' : conversion from '' to 'unsigned int', signed/unsigned mismatch

xerces-c-src_2_7_0\src\xercesc\framework\psvi\XSValue.cpp(1721) : warning C4189: 'strLen' : local variable is initialized but not referenced

xerces-c-src_2_7_0\src\xercesc\dom\deprecated\DOM_RangeException.cpp(36) : warning C4244: 'argument' : conversion from 'xercesc_2_7::DOM_RangeException::RangeExceptionCode' to 'short', possible loss of data


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


[jira] Commented: (XERCESC-1593) critical Warning on compiling XercesC 2.7.0

Posted by "Lukas Grützmacher (JIRA)" <xe...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XERCESC-1593?page=comments#action_12383179 ] 

Lukas Grützmacher commented on XERCESC-1593:
--------------------------------------------

I've checked again now the code at traverseschema.cpp:6490. Now I agree that the code looks safe now. But it is really hard to understand.

I know there are many compilers in the world. But I think MSVC is one of the major compilers for the Windows platform ("your" binary release is also build by MSVC, isn't it?). So why not take advantages from this compiler. Yes, it has not found out that the code is currently safe. But I was also not able to see this first time ;)

I want to explain my target "always warning free". In the past I've made the experiance that compiling in warning level 4 can really find problems in the code, e.g. unititialized values which really occur. So we (my company) has decided to enforce level 4. Then it is easier to fix all warnings instead of reviewing all warnings each time of recompile.

Further: Now you have checked that the warning at traverseschema.cpp:6490 is not critical and you keep this state in your mind. Later on somebody changes the code around so that is not safe anymore. But you may not check anymore this warning and you may really run into problems.

For the problem of initial values I want to give an example:
change
  XMLAttDef::DefAttTypes defAttType; (traverseschema.cpp:6449)
to
  XMLAttDef::DefAttTypes defAttType = XMLAttDef::DefAttTypes_Unknown;

In the case the value is really not overwritten and so used with DefAttTypes_Unknown it is better to check against DefAttTypes_Unknown instead of checking all other expected values. If it is really always overwritten so this "costs" are only "DWORD PTR _defAttType$27151[ebp], -1".

> critical Warning on compiling XercesC 2.7.0
> -------------------------------------------
>
>          Key: XERCESC-1593
>          URL: http://issues.apache.org/jira/browse/XERCESC-1593
>      Project: Xerces-C++
>         Type: Bug

>   Components: Build
>     Versions: 2.7.0
>  Environment: MSVC 2003 (7.1)
> Set Warning Level to 4
>     Reporter: Lukas Grützmacher

>
> I've compiled XercesC 2.7.0 from sources with MSVC2003.
> I've changed the project settings to use always warning level 4.
> Thereby I found a lot of warnings. IMHO some of them are critical:
> xerces-c-src_2_7_0\src\xercesc\validators\schema\traverseschema.cpp(6490) : warning C4701: local variable 'defAttType' may be used without having been initialized
> xerces-c-src_2_7_0\src\xercesc\util\regx\token.cpp(259) : warning C4701: local variable 'ret2' may be used without having been initialized
> xerces-c-src_2_7_0\src\xercesc\util\regx\RegularExpression.cpp(184) : warning C4244: 'argument' : conversion from 'XMLInt32' to 'const XMLCh', possible loss of data
> xerces-c-src_2_7_0\src\xercesc\util\platforms\win32\win32platformutils.cpp(795) : warning C4701: local variable 'retVal' may be used without having been initialized
> xerces-c-src_2_7_0\tests\xserializertest\xserializertest.cpp(537) : warning C4701: local variable 'duration' may be used without having been initialized
> Many others are not critical but sould be fixed, too. Here are some examples:
> DFAContentModel.cpp
> ..\..\..\..\..\src\xercesc\validators\common\CMNode.hpp(129) : warning C4245: 'initializing' : conversion from 'int' to 'unsigned int', signed/unsigned mismatch
> xerces-c-src_2_7_0\src\xercesc\internal\XSAXMLScanner.cpp(310) : warning C4245: 'argument' : conversion from '' to 'unsigned int', signed/unsigned mismatch
> xerces-c-src_2_7_0\src\xercesc\framework\psvi\XSValue.cpp(1721) : warning C4189: 'strLen' : local variable is initialized but not referenced
> xerces-c-src_2_7_0\src\xercesc\dom\deprecated\DOM_RangeException.cpp(36) : warning C4244: 'argument' : conversion from 'xercesc_2_7::DOM_RangeException::RangeExceptionCode' to 'short', possible loss of data

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


[jira] Commented: (XERCESC-1593) critical Warning on compiling XercesC 2.7.0

Posted by "Lukas Grützmacher (JIRA)" <xe...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XERCESC-1593?page=comments#action_12379078 ] 

Lukas Grützmacher commented on XERCESC-1593:
--------------------------------------------

It may be safe in special case. But do you want to analyze each time all warnings?
My recommendation is to make the code always warning free.
What is the problem to initialize all these variables?

> critical Warning on compiling XercesC 2.7.0
> -------------------------------------------
>
>          Key: XERCESC-1593
>          URL: http://issues.apache.org/jira/browse/XERCESC-1593
>      Project: Xerces-C++
>         Type: Bug

>   Components: Build
>     Versions: 2.7.0
>  Environment: MSVC 2003 (7.1)
> Set Warning Level to 4
>     Reporter: Lukas Grützmacher

>
> I've compiled XercesC 2.7.0 from sources with MSVC2003.
> I've changed the project settings to use always warning level 4.
> Thereby I found a lot of warnings. IMHO some of them are critical:
> xerces-c-src_2_7_0\src\xercesc\validators\schema\traverseschema.cpp(6490) : warning C4701: local variable 'defAttType' may be used without having been initialized
> xerces-c-src_2_7_0\src\xercesc\util\regx\token.cpp(259) : warning C4701: local variable 'ret2' may be used without having been initialized
> xerces-c-src_2_7_0\src\xercesc\util\regx\RegularExpression.cpp(184) : warning C4244: 'argument' : conversion from 'XMLInt32' to 'const XMLCh', possible loss of data
> xerces-c-src_2_7_0\src\xercesc\util\platforms\win32\win32platformutils.cpp(795) : warning C4701: local variable 'retVal' may be used without having been initialized
> xerces-c-src_2_7_0\tests\xserializertest\xserializertest.cpp(537) : warning C4701: local variable 'duration' may be used without having been initialized
> Many others are not critical but sould be fixed, too. Here are some examples:
> DFAContentModel.cpp
> ..\..\..\..\..\src\xercesc\validators\common\CMNode.hpp(129) : warning C4245: 'initializing' : conversion from 'int' to 'unsigned int', signed/unsigned mismatch
> xerces-c-src_2_7_0\src\xercesc\internal\XSAXMLScanner.cpp(310) : warning C4245: 'argument' : conversion from '' to 'unsigned int', signed/unsigned mismatch
> xerces-c-src_2_7_0\src\xercesc\framework\psvi\XSValue.cpp(1721) : warning C4189: 'strLen' : local variable is initialized but not referenced
> xerces-c-src_2_7_0\src\xercesc\dom\deprecated\DOM_RangeException.cpp(36) : warning C4244: 'argument' : conversion from 'xercesc_2_7::DOM_RangeException::RangeExceptionCode' to 'short', possible loss of data

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


[jira] Closed: (XERCESC-1593) critical Warning on compiling XercesC 2.7.0

Posted by "Boris Kolpackov (JIRA)" <xe...@xml.apache.org>.
     [ https://issues.apache.org/jira/browse/XERCESC-1593?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Boris Kolpackov closed XERCESC-1593.
------------------------------------

       Resolution: Fixed
    Fix Version/s: 3.0.1

Presumably fixed in 3.0.1. Please verify and re-open if you believe this is still an issue.

> critical Warning on compiling XercesC 2.7.0
> -------------------------------------------
>
>                 Key: XERCESC-1593
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1593
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Build
>    Affects Versions: 2.7.0
>         Environment: MSVC 2003 (7.1)
> Set Warning Level to 4
>            Reporter: Lukas Grützmacher
>             Fix For: 3.0.1
>
>
> I've compiled XercesC 2.7.0 from sources with MSVC2003.
> I've changed the project settings to use always warning level 4.
> Thereby I found a lot of warnings. IMHO some of them are critical:
> xerces-c-src_2_7_0\src\xercesc\validators\schema\traverseschema.cpp(6490) : warning C4701: local variable 'defAttType' may be used without having been initialized
> xerces-c-src_2_7_0\src\xercesc\util\regx\token.cpp(259) : warning C4701: local variable 'ret2' may be used without having been initialized
> xerces-c-src_2_7_0\src\xercesc\util\regx\RegularExpression.cpp(184) : warning C4244: 'argument' : conversion from 'XMLInt32' to 'const XMLCh', possible loss of data
> xerces-c-src_2_7_0\src\xercesc\util\platforms\win32\win32platformutils.cpp(795) : warning C4701: local variable 'retVal' may be used without having been initialized
> xerces-c-src_2_7_0\tests\xserializertest\xserializertest.cpp(537) : warning C4701: local variable 'duration' may be used without having been initialized
> Many others are not critical but sould be fixed, too. Here are some examples:
> DFAContentModel.cpp
> ..\..\..\..\..\src\xercesc\validators\common\CMNode.hpp(129) : warning C4245: 'initializing' : conversion from 'int' to 'unsigned int', signed/unsigned mismatch
> xerces-c-src_2_7_0\src\xercesc\internal\XSAXMLScanner.cpp(310) : warning C4245: 'argument' : conversion from '' to 'unsigned int', signed/unsigned mismatch
> xerces-c-src_2_7_0\src\xercesc\framework\psvi\XSValue.cpp(1721) : warning C4189: 'strLen' : local variable is initialized but not referenced
> xerces-c-src_2_7_0\src\xercesc\dom\deprecated\DOM_RangeException.cpp(36) : warning C4244: 'argument' : conversion from 'xercesc_2_7::DOM_RangeException::RangeExceptionCode' to 'short', possible loss of data

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


[jira] Commented: (XERCESC-1593) critical Warning on compiling XercesC 2.7.0

Posted by "Jesse Pelton (JIRA)" <xe...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XERCESC-1593?page=comments#action_12379088 ] 

Jesse Pelton commented on XERCESC-1593:
---------------------------------------

While I agree that ideal code compiles without warnings, there are many compilers in the world, each with its own criteria for generating warnings. Today's "clean" code may cause a future compiler to spew endless warnings. Furthermore, some compilers aren't especially smart about the warnings they generate. In the code I looked at, a more sophisticated compiler would have determined that the code was safe and skipped the warnings.

I'm skeptical of the notion of altering code purely to silence a compiler that generates needless warnings. For instance, in the cases I looked at, it's not clear what appropriate initial values would be; choosing some arbitrary value could make the code harder to really understand, which is a step backward.

Remember that I pointed out that the code I looked at is hard to understand. If it's restructured to make it easier for humans to understand, I think there's a good chance that compilers will be able to analyze it more successfully. Warnings should be viewed as a hint that you might want to rethink your code, not as a mandate to revise it.

In any case, if you believe you have a solution, I imagine that a patch would be welcome. If you make a patch against the current code in SVN, it will be easier to review and apply.

> critical Warning on compiling XercesC 2.7.0
> -------------------------------------------
>
>          Key: XERCESC-1593
>          URL: http://issues.apache.org/jira/browse/XERCESC-1593
>      Project: Xerces-C++
>         Type: Bug

>   Components: Build
>     Versions: 2.7.0
>  Environment: MSVC 2003 (7.1)
> Set Warning Level to 4
>     Reporter: Lukas Grützmacher

>
> I've compiled XercesC 2.7.0 from sources with MSVC2003.
> I've changed the project settings to use always warning level 4.
> Thereby I found a lot of warnings. IMHO some of them are critical:
> xerces-c-src_2_7_0\src\xercesc\validators\schema\traverseschema.cpp(6490) : warning C4701: local variable 'defAttType' may be used without having been initialized
> xerces-c-src_2_7_0\src\xercesc\util\regx\token.cpp(259) : warning C4701: local variable 'ret2' may be used without having been initialized
> xerces-c-src_2_7_0\src\xercesc\util\regx\RegularExpression.cpp(184) : warning C4244: 'argument' : conversion from 'XMLInt32' to 'const XMLCh', possible loss of data
> xerces-c-src_2_7_0\src\xercesc\util\platforms\win32\win32platformutils.cpp(795) : warning C4701: local variable 'retVal' may be used without having been initialized
> xerces-c-src_2_7_0\tests\xserializertest\xserializertest.cpp(537) : warning C4701: local variable 'duration' may be used without having been initialized
> Many others are not critical but sould be fixed, too. Here are some examples:
> DFAContentModel.cpp
> ..\..\..\..\..\src\xercesc\validators\common\CMNode.hpp(129) : warning C4245: 'initializing' : conversion from 'int' to 'unsigned int', signed/unsigned mismatch
> xerces-c-src_2_7_0\src\xercesc\internal\XSAXMLScanner.cpp(310) : warning C4245: 'argument' : conversion from '' to 'unsigned int', signed/unsigned mismatch
> xerces-c-src_2_7_0\src\xercesc\framework\psvi\XSValue.cpp(1721) : warning C4189: 'strLen' : local variable is initialized but not referenced
> xerces-c-src_2_7_0\src\xercesc\dom\deprecated\DOM_RangeException.cpp(36) : warning C4244: 'argument' : conversion from 'xercesc_2_7::DOM_RangeException::RangeExceptionCode' to 'short', possible loss of data

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


[jira] Commented: (XERCESC-1593) critical Warning on compiling XercesC 2.7.0

Posted by "Jesse Pelton (JIRA)" <xe...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XERCESC-1593?page=comments#action_12379077 ] 

Jesse Pelton commented on XERCESC-1593:
---------------------------------------

These may or may not actually be problems. I took a look at the code that causes the first warning to be generated (in TraverseSchem.cpp) and concluded that it's safe. That said, I had to look at it pretty closely to reach this conclusion because the logic is a bit obscure. (It's clear that the offending statement can't be reached unless completeWildCard is set, but it's not obvious that if completeWildCard is set, defAttType will also be set.)

Likewise for Token.cpp: it's safe, but a bit obscure.

Bottom line: while these warnings correlate to code that is somewhat hard to read, careful analysis of each instance is required to determine whether there's actually anything wrong and whether there's an alternative that's easier for humans and compilers to analyze, correct, and efficient. A patch, anyone?

> critical Warning on compiling XercesC 2.7.0
> -------------------------------------------
>
>          Key: XERCESC-1593
>          URL: http://issues.apache.org/jira/browse/XERCESC-1593
>      Project: Xerces-C++
>         Type: Bug

>   Components: Build
>     Versions: 2.7.0
>  Environment: MSVC 2003 (7.1)
> Set Warning Level to 4
>     Reporter: Lukas Grützmacher

>
> I've compiled XercesC 2.7.0 from sources with MSVC2003.
> I've changed the project settings to use always warning level 4.
> Thereby I found a lot of warnings. IMHO some of them are critical:
> xerces-c-src_2_7_0\src\xercesc\validators\schema\traverseschema.cpp(6490) : warning C4701: local variable 'defAttType' may be used without having been initialized
> xerces-c-src_2_7_0\src\xercesc\util\regx\token.cpp(259) : warning C4701: local variable 'ret2' may be used without having been initialized
> xerces-c-src_2_7_0\src\xercesc\util\regx\RegularExpression.cpp(184) : warning C4244: 'argument' : conversion from 'XMLInt32' to 'const XMLCh', possible loss of data
> xerces-c-src_2_7_0\src\xercesc\util\platforms\win32\win32platformutils.cpp(795) : warning C4701: local variable 'retVal' may be used without having been initialized
> xerces-c-src_2_7_0\tests\xserializertest\xserializertest.cpp(537) : warning C4701: local variable 'duration' may be used without having been initialized
> Many others are not critical but sould be fixed, too. Here are some examples:
> DFAContentModel.cpp
> ..\..\..\..\..\src\xercesc\validators\common\CMNode.hpp(129) : warning C4245: 'initializing' : conversion from 'int' to 'unsigned int', signed/unsigned mismatch
> xerces-c-src_2_7_0\src\xercesc\internal\XSAXMLScanner.cpp(310) : warning C4245: 'argument' : conversion from '' to 'unsigned int', signed/unsigned mismatch
> xerces-c-src_2_7_0\src\xercesc\framework\psvi\XSValue.cpp(1721) : warning C4189: 'strLen' : local variable is initialized but not referenced
> xerces-c-src_2_7_0\src\xercesc\dom\deprecated\DOM_RangeException.cpp(36) : warning C4244: 'argument' : conversion from 'xercesc_2_7::DOM_RangeException::RangeExceptionCode' to 'short', possible loss of data

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org