You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Alona Rossen <ar...@opentext.com> on 2010/01/22 16:38:32 UTC

xerces-c 3.0.1 build fails on HP-UX 11.00 with aCC A.03.35

Hello, 

 

I receive the following error when I build xerces-c 3.0.1 with aCC: HP
ANSI C++ B3910B A.03.35:

 

Error 742: "xercesc/util/NetAccessors/BinHTTPInputStreamCommon.cpp",
line 260

    # Source type unsigned short *const and target type unsigned short
*& in a

    const_cast can only differ in their qualifiers

            const_cast<XMLCh*&>(fContentType) =
const_cast<BinHTTPInputStreamCo

 

Is there a tested solution/fix for this problem?

 

Thank you, 

Alona


Re: xerces-c 3.0.1 build fails on HP-UX 11.00 with aCC A.03.35

Posted by David Bertoni <db...@apache.org>.
On 1/26/2010 1:03 AM, Boris Kolpackov wrote:
> Hi David,
>
> David Bertoni<db...@apache.org>  writes:
>
>> const_cast<BinHTTPInputStreamCommon*>(this)->fContentType =
>> const_cast<BinHTTPInputStreamCommon*>(this)->findHeader("Content-Type");
>
> I have made this change for the upcoming 3.1.0.
Great!

>> We really should just make this data member mutable, since the code as
>> it stands results in undefined behavior.
>
> Agree about mutable, though it is not used anywhere in the code base
> yet. As for the undefined behavior, it will only be the case if someone
> creates a const BinHTTPInputStreamCommon object, which is very unlikely
> to happen.
Sorry, I should have been more specific. I just don't like seeing a 10+ 
year-old idiom to work around the missing "mutable" keyword.

Do we really think there are compilers out there that don't support the 
"mutable" keyword that are still in use? At some point we have to leave 
the past behind, and it would certainly make the code cleaner to allow 
this keyword.

Dave

Re: xerces-c 3.0.1 build fails on HP-UX 11.00 with aCC A.03.35

Posted by Boris Kolpackov <bo...@codesynthesis.com>.
Hi David,

David Bertoni <db...@apache.org> writes:

> const_cast<BinHTTPInputStreamCommon*>(this)->fContentType =
> const_cast<BinHTTPInputStreamCommon*>(this)->findHeader("Content-Type");

I have made this change for the upcoming 3.1.0.


> We really should just make this data member mutable, since the code as  
> it stands results in undefined behavior.

Agree about mutable, though it is not used anywhere in the code base
yet. As for the undefined behavior, it will only be the case if someone
creates a const BinHTTPInputStreamCommon object, which is very unlikely
to happen.

Boris

-- 
Boris Kolpackov, Code Synthesis        http://codesynthesis.com/~boris/blog
Open-source XML data binding for C++   http://codesynthesis.com/products/xsd
XML data binding for embedded systems  http://codesynthesis.com/products/xsde
Command line interface to C++ compiler http://codesynthesis.com/projects/cli

RE: xerces-c 3.0.1 build fails on HP-UX 11.00 with aCC A.03.35

Posted by Alona Rossen <ar...@opentext.com>.
My appoligies. Dave's code has been accepted by the compiler after I
compiled newly installed sources.

- Alona

-----Original Message-----
From: Alona Rossen 
Sent: Monday, January 25, 2010 10:58 AM
To: 'c-users@xerces.apache.org'
Subject: RE: xerces-c 3.0.1 build fails on HP-UX 11.00 with aCC A.03.35

Hi Dave, 

The compiler did not accept your solution either.
This is how I handled it:

BinHTTPInputStreamCommon.hpp:

class XMLUTIL_EXPORT BinHTTPInputStreamCommon : public BinInputStream
{
public :
    virtual XMLFilePos curPos() const;
    virtual XMLSize_t readBytes
    (
                XMLByte* const  toFill
        , const XMLSize_t    maxToRead
    );

    virtual const XMLCh *getContentType() const{};
    virtual const XMLCh *getContentType();

protected :
    BinHTTPInputStreamCommon(MemoryManager *manager);
    virtual ~BinHTTPInputStreamCommon();
..........................
..........................
}

BinHTTPInputStreamCommon.cpp:

const XMLCh *BinHTTPInputStreamCommon::getContentType()
{
    if(fContentType == 0) {
        // mutable
        //const_cast<XMLCh*&>(fContentType) =
const_cast<BinHTTPInputStreamCommo
n*>(this)->findHeader("Content-Type");
        fContentType =
const_cast<BinHTTPInputStreamCommon*>(this)->findHeader("
Content-Type");
    }
    return fContentType;
}


There is one derivation from BinHTTPInputStreamCommon:

class XMLUTIL_EXPORT UnixHTTPURLInputStream : public
BinHTTPInputStreamCommon

However, UnixHTTPURLInputStream does not redefine getContentType().

Regards, 
Alona

-----Original Message-----
From: David Bertoni [mailto:dbertoni@apache.org] 
Sent: Friday, January 22, 2010 6:09 PM
To: c-users@xerces.apache.org
Subject: Re: xerces-c 3.0.1 build fails on HP-UX 11.00 with aCC A.03.35

On 1/22/2010 7:38 AM, Alona Rossen wrote:
> Hello,
>
> I receive the following error when I build xerces-c 3.0.1 with aCC: HP
> ANSI C++ B3910B A.03.35:
>
> Error 742: "xercesc/util/NetAccessors/BinHTTPInputStreamCommon.cpp",
> line 260
>      # Source type unsigned short *const and target type unsigned
short
> *&  in a
>      const_cast can only differ in their qualifiers
>              const_cast<XMLCh*&>(fContentType) =
> const_cast<BinHTTPInputStreamCo
This is an "interesting" way of modifying a data member in a const 
member function.  Can you try this instead, to see if it works?

const_cast<BinHTTPInputStreamCommon*>(this)->fContentType =
const_cast<BinHTTPInputStreamCommon*>(this)->findHeader("Content-Type");

We really should just make this data member mutable, since the code as 
it stands results in undefined behavior.

Dave

RE: xerces-c 3.0.1 build fails on HP-UX 11.00 with aCC A.03.35

Posted by Alona Rossen <ar...@opentext.com>.
Hi Dave, 

The compiler did not accept your solution either.
This is how I handled it:

BinHTTPInputStreamCommon.hpp:

class XMLUTIL_EXPORT BinHTTPInputStreamCommon : public BinInputStream
{
public :
    virtual XMLFilePos curPos() const;
    virtual XMLSize_t readBytes
    (
                XMLByte* const  toFill
        , const XMLSize_t    maxToRead
    );

    virtual const XMLCh *getContentType() const{};
    virtual const XMLCh *getContentType();

protected :
    BinHTTPInputStreamCommon(MemoryManager *manager);
    virtual ~BinHTTPInputStreamCommon();
..........................
..........................
}

BinHTTPInputStreamCommon.cpp:

const XMLCh *BinHTTPInputStreamCommon::getContentType()
{
    if(fContentType == 0) {
        // mutable
        //const_cast<XMLCh*&>(fContentType) =
const_cast<BinHTTPInputStreamCommo
n*>(this)->findHeader("Content-Type");
        fContentType =
const_cast<BinHTTPInputStreamCommon*>(this)->findHeader("
Content-Type");
    }
    return fContentType;
}


There is one derivation from BinHTTPInputStreamCommon:

class XMLUTIL_EXPORT UnixHTTPURLInputStream : public
BinHTTPInputStreamCommon

However, UnixHTTPURLInputStream does not redefine getContentType().

Regards, 
Alona

-----Original Message-----
From: David Bertoni [mailto:dbertoni@apache.org] 
Sent: Friday, January 22, 2010 6:09 PM
To: c-users@xerces.apache.org
Subject: Re: xerces-c 3.0.1 build fails on HP-UX 11.00 with aCC A.03.35

On 1/22/2010 7:38 AM, Alona Rossen wrote:
> Hello,
>
> I receive the following error when I build xerces-c 3.0.1 with aCC: HP
> ANSI C++ B3910B A.03.35:
>
> Error 742: "xercesc/util/NetAccessors/BinHTTPInputStreamCommon.cpp",
> line 260
>      # Source type unsigned short *const and target type unsigned
short
> *&  in a
>      const_cast can only differ in their qualifiers
>              const_cast<XMLCh*&>(fContentType) =
> const_cast<BinHTTPInputStreamCo
This is an "interesting" way of modifying a data member in a const 
member function.  Can you try this instead, to see if it works?

const_cast<BinHTTPInputStreamCommon*>(this)->fContentType =
const_cast<BinHTTPInputStreamCommon*>(this)->findHeader("Content-Type");

We really should just make this data member mutable, since the code as 
it stands results in undefined behavior.

Dave

Re: xerces-c 3.0.1 build fails on HP-UX 11.00 with aCC A.03.35

Posted by David Bertoni <db...@apache.org>.
On 1/22/2010 7:38 AM, Alona Rossen wrote:
> Hello,
>
> I receive the following error when I build xerces-c 3.0.1 with aCC: HP
> ANSI C++ B3910B A.03.35:
>
> Error 742: "xercesc/util/NetAccessors/BinHTTPInputStreamCommon.cpp",
> line 260
>      # Source type unsigned short *const and target type unsigned short
> *&  in a
>      const_cast can only differ in their qualifiers
>              const_cast<XMLCh*&>(fContentType) =
> const_cast<BinHTTPInputStreamCo
This is an "interesting" way of modifying a data member in a const 
member function.  Can you try this instead, to see if it works?

const_cast<BinHTTPInputStreamCommon*>(this)->fContentType =
const_cast<BinHTTPInputStreamCommon*>(this)->findHeader("Content-Type");

We really should just make this data member mutable, since the code as 
it stands results in undefined behavior.

Dave