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 "Maciek Samsel (JIRA)" <xe...@xml.apache.org> on 2005/03/16 21:48:23 UTC

[jira] Created: (XERCESC-1379) XSSimpleTypeDefinition constructor - declaration and definition of a variable at the "if" check causes compiler error

XSSimpleTypeDefinition constructor - declaration and definition of a variable at the "if" check causes compiler error
---------------------------------------------------------------------------------------------------------------------

         Key: XERCESC-1379
         URL: http://issues.apache.org/jira/browse/XERCESC-1379
     Project: Xerces-C++
        Type: Bug
    Versions: 2.6.0    
 Environment: Solaris 2.8 with SPARCompiler 4.2
    Reporter: Maciek Samsel


Line 100, File: xerces-c-src_2_6_0/src/xercesc/framework/psvi/XSSimpleTypeDefinition.cpp

This is bad style of programming and what's more it will not work with a few compilers. You are not supposed to define and assign value inside "if" construct. Commercial SPARCompiler 4.2 reports error of malformed line and does not allow to complete.

Although rich language syntax of C++ allows for many approaches some of them are not the best and should be avoided. The readabilty of the code is the main principle as we departure from obfuscated ways of writing expressions inherited from C programming styles like 20 years ago.

Please fix line:
    if (int finalset = fDatatypeValidator->getFinalSet())

replacing it with:
    int finalset = fDatatypeValidator->getFinalSet();
    if (finalset)
 

(it is a local variable used in that block only so there is no conflicts).

Anyway how much performance do you gain with that check? (see the code after it)


-- 
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
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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


[jira] Resolved: (XERCESC-1379) XSSimpleTypeDefinition constructor - declaration and definition of a variable at the "if" check causes compiler error

Posted by "Alberto Massari (JIRA)" <xe...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XERCESC-1379?page=history ]
     
Alberto Massari resolved XERCESC-1379:
--------------------------------------

    Resolution: Fixed

The fix is in CVS. Please verify.

Alberto

> XSSimpleTypeDefinition constructor - declaration and definition of a variable at the "if" check causes compiler error
> ---------------------------------------------------------------------------------------------------------------------
>
>          Key: XERCESC-1379
>          URL: http://issues.apache.org/jira/browse/XERCESC-1379
>      Project: Xerces-C++
>         Type: Bug
>     Versions: 2.6.0
>  Environment: Solaris 2.8 with SPARCompiler 4.2
>     Reporter: Maciek Samsel

>
> Line 100, File: xerces-c-src_2_6_0/src/xercesc/framework/psvi/XSSimpleTypeDefinition.cpp
> This is bad style of programming and what's more it will not work with a few compilers. You are not supposed to define and assign value inside "if" construct. Commercial SPARCompiler 4.2 reports error of malformed line and does not allow to complete.
> Although rich language syntax of C++ allows for many approaches some of them are not the best and should be avoided. The readabilty of the code is the main principle as we departure from obfuscated ways of writing expressions inherited from C programming styles like 20 years ago.
> Please fix line:
>     if (int finalset = fDatatypeValidator->getFinalSet())
> replacing it with:
>     int finalset = fDatatypeValidator->getFinalSet();
>     if (finalset)
>  
> (it is a local variable used in that block only so there is no conflicts).
> Anyway how much performance do you gain with that check? (see the code after it)

-- 
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
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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