Warnings in the Runtime

Bug #866725 reported by David Graf
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zorba
Incomplete
Medium
Paul J. Lucas

Bug Description

In Zorba, there is some chaos with the types of length variables. They have the type xqp_long, xqp_ulong, long, ulong, etc.. Therefore, the following warnings are shown if I compile zorba on windows:

src\runtime\sequences\sequences_impl.cpp(477) : warning C4244: '=' : conversion from 'double' to 'zorba::xqp_long', possible loss of data
src\runtime\sequences\sequences_impl.cpp(482) : warning C4244: '=' : conversion from 'double' to 'zorba::xqp_long', possible loss of data
src\runtime\collections\collections_impl.cpp(1165) : warning C4244: 'argument' : conversion from 'zorba::xqp_ulong' to 'ulong', possible loss of data

src\runtime\core\var_iterators.cpp(341) : warning C4244: 'argument' : conversion from 'zorba::xqp_long' to 'ulong', possible loss of data
src\runtime\core\var_iterators.cpp(378) : warning C4244: '=' : conversion from 'zorba::xqp_long' to 'ulong', possible loss of data
src\runtime\core\var_iterators.cpp(379) : warning C4244: '=' : conversion from 'zorba::xqp_long' to 'ulong', possible loss of data
src\runtime\core\var_iterators.cpp(630) : warning C4244: 'argument' : conversion from 'zorba::xqp_long' to 'ulong', possible loss of data
src\runtime\core\var_iterators.cpp(656) : warning C4244: 'argument' : conversion from 'zorba::xqp_long' to 'ulong', possible loss of data
src\runtime\core\var_iterators.cpp(735) : warning C4244: 'argument' : conversion from 'zorba::xqp_long' to 'ulong', possible loss of data
src\runtime\core\var_iterators.cpp(755) : warning C4244: '=' : conversion from 'zorba::xqp_long' to 'ulong', possible loss of data
src\runtime\core\var_iterators.cpp(756) : warning C4244: '=' : conversion from 'zorba::xqp_long' to 'ulong', possible loss of data

src\store\naive\loader_fast.cpp(218) : warning C4244: 'return' : conversion from 'std::streamsize' to 'long', possible loss of data
src\store\naive\loader_dtd.cpp(221) : warning C4244: 'return' : conversion from 'std::streamsize' to 'long', possible loss of data
src\store\naive\loader_dtd.cpp(273) : warning C4244: 'initializing' : conversion from 'std::streamoff' to 'size_t', possible loss of data

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

Quoting David's email on this:

Unfortunately, this is not a straight forward task because we have a little type mess. For example in src/runtime/collections/collections_impl.cpp:1164, a xs_ulong is subtracted from a ulong and the result passed to a function that accepts ulong. Therefore, a warning is shown on Windows.

We have several situations like this in runtime code. I think, we should forbid to cast away XQuery types in the runtime. Especially if they are passed via XQuery function parameters to the runtime. I think, the only reason why these castings are done is because of the implementation of the store (e.g. the nodes of a collection are saved in a vector ...). Therefore, the castings should be done inside the store and not outside. They are store implementation dependent. Thus, store functions like Collection::nodeAt(...) should expect XQuery types. xs_integer or xs_unsignedLong. And in the long run, the store should throw an error if it detects an overflow. Or maybe, it is able to handle XQuery types some day and does not have to cast them at all. But the decision what to do with the XQuery types should be taken by the store only!

This change would also have consequences to the Zorba API. E.g. Collection::size() returns an unsigned long currently. But the fn:count function of XQuery returns xs:integer. I think, Collection::size() should return xs:integer too. I am not sure if the value should be returned wrapped in an Item or as a value of the type xs_integer. But it should definitely be returned without being casted to different type.

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

Fixing this issue is related to cleaning up other type-related issues such as using arbitrarily sized integers (which dramatically harm performance) even if the user doesn't need that feature.

Fixing this is postponed until there is a general decision of what we do in this case.

Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

The store API has been cleaned up (i.e. xs:integer) is used as a datatype for the length of a sequence. This should enable us to fix the runtime warnings.

Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) wrote :

Marked with Resolution = None at Dana's request.

Revision history for this message
David Graf (davidagraf) wrote :

This is the current build output on windows (trunk revision 10758). Need to check if some of the warnings can be fixed easily.

Changed in zorba:
status: New → In Progress
Revision history for this message
David Graf (davidagraf) wrote :

Hint for myself: went through till 46%.

Changed in zorba:
status: In Progress → New
assignee: David Graf (davidagraf) → Dana Florescu (dflorescu)
assignee: Dana Florescu (dflorescu) → Paul J. Lucas (paul-lucas)
milestone: none → 3.0
Changed in zorba:
importance: High → Medium
Chris Hillery (ceejatec)
tags: removed: core-runtime
Revision history for this message
Paul J. Lucas (paul-lucas) wrote :

Since I don't develop on Windows, it's not clear how I'm supposed to work on this.

Changed in zorba:
status: New → Incomplete
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.