Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-1379

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.6.0
    • 2.7.0
    • None
    • None
    • Solaris 2.8 with SPARCompiler 4.2

    Description

      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)

      Attachments

        Activity

          People

            Unassigned Unassigned
            macieks Maciek Samsel
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: