[xsd-users] Polymorphic problems.
Bill Pringlemeir
bpringle at sympatico.ca
Tue Dec 2 15:13:46 EST 2008
On 2 Dec 2008, boris at codesynthesis.com wrote:
> Bill Pringlemeir <bpringle at sympatico.ca> writes:
>> If the std::map only uses the 'before' functionality, then how does
>> find() know when it has found an identical value versus one that is
>> !before() or after?
> When (!before (x, y) && !before (y, x)), x == y.
Hmm. Very right!
>> The following test case demonstrates the problem. This fails on
>> various versions of gcc. However for the type-serializer-map.[th]xx
>> to fail, the platform must have typeid() that return different
>> pointers.
[snip]
> This is not how type-serializer-map works. To make it emulate
> type-serializer-map, this code needs to be changed like so:
> struct type_id_comparator
> {
> bool
> operator() (const char* x, const char* y) const
> {
> return strcmp (x, y) < 0;
> }
> };
Sorry, I was being lazy. gcc implements it with pointer comparison,
but I see that it has a particular comment saying that the type_infos
are gaurenteed to be identical. AIX has,
inline bool type_info::before(const type_info&x) const {
return (&x!=this) && (strcmp(x.mangledName,this->mangledName)>=0);
}
However, I made your change and I still get the following output,
bpringle at pvr:~$ g++ -Wall test.cc -o test; ./test
No match.
We have a match.
key1: 0x804a070 compare: 0x804c0e8 value: 0x804a070
bpringle at pvr:~$ g++ -DTEST_STR -Wall test.cc -o test; ./test
We have a match.
We have a match.
key1: 0xbfa499cc compare: 0xbfa499bc value: 0x804a490
bpringle at pvr:~$ g++ --version
g++ (GCC) 4.2.0
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
With gcc 3.4.6 I have different std::string addresses, but the same
results for std::string. Did you make other changes? I looked at the
gcc implementation of the map and you are correct. It seems that
'(!before (x, y) && !before (y, x))' is used... but I still get the
output above. I tried different variants of the strcmp and never got
the pointers to work. I think you are correct that it should work;
but can you let me know why it is not? It must still be an error in
my test code.
> This means that std::map in XL C++ works as expected and the
> problem is somewhere else. Would it be possible for you to
> come up with a test case that demonstrates the problem on AIX
> with XL C++? Something that recreates your shared object
> structure but uses dummy schemas?
We have xlC version 6.0. Maybe this is not supported. I am pretty
sure that this is the problem in our system. We have put debug in
type-serializer-map.txx and the class is registered, the same class
name is used during a serialization attempt from another module, but
the no_type_info exception is thrown.
It (no_type_info exceptions) seems to happen with polymorphic
customizations on AIX. The same exception is not thrown on Linux. I
will try to work on a test case; it is rather difficult as I don't
understand the problem. I believe that it is serializing a customized
child. The schema source lives in a seperate shared library and the
executable creates the object and attempts to serialize it. The
no_type_info is only thrown on AIX. It could also be with static
initializers... although the routine is well into the main line...
Thanks again,
Bill Pringlemeir.
--
Programming is like sex. One mistake and you have to support it for the
rest of your life. - Michael Sinz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.cc
Type: text/x-c++src
Size: 1377 bytes
Desc: A test file.
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20081202/1345cfc4/test.cc
More information about the xsd-users
mailing list