[bug #45833] support load/save of classdef objects

Markus Mützel <[email protected]>
Newsgroups gmane.comp.gnu.octave.bugs
Message-ID <[email protected]>
Please use the bug tracker to post updates to a bug report.  The mailing list is intended as a read-only notification stream.  Info posted to this mailing list address won't appear in the tracker database where it is most useful.

Follow-up Comment #95, bug #45833 (group octave):

There are a couple of compiler warnings when building Octave for a 32-bit
target.
E.g.,
https://github.com/gnu-octave/octave/actions/runs/21731757111/job/62687797007#step:13:4312

../libinterp/corefcn/ls-mat-subsys.cc: In function 'octave_value
octave::load_mcos_object(const octave_value&, bool)':
../libinterp/corefcn/ls-mat-subsys.cc:174:33: warning: comparison of integer
expressions of different signedness: 'octave_idx_type' {aka 'int'} and
'uint32_t' {aka 'unsigned int'} [-Wsign-compare]
  174 |   for (octave_idx_type i = 0; i < objdims; i++)
      |                               ~~^~~~~~~~~
../libinterp/corefcn/ls-mat-subsys.cc: In member function 'bool
octave::subsystem_handler::read_filewrapper(const Cell&, bool)':
../libinterp/corefcn/ls-mat-subsys.cc:326:22: warning: cast from 'const
octave_int<unsigned char>*' to 'const uint32_t*' {aka 'const unsigned int*'}
increases required alignment of target type [-Wcast-align]
  326 |   uint32_t version = reinterpret_cast<const uint32_t&>
(fwrap_metadata_array(0));
      |
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../libinterp/corefcn/ls-mat-subsys.cc:335:17: warning: cast from 'const
octave_int<unsigned char>*' to 'const uint32_t*' {aka 'const unsigned int*'}
increases required alignment of target type [-Wcast-align]
  335 |   m_num_names = reinterpret_cast<const uint32_t&>
(fwrap_metadata_array(4));
      |
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../libinterp/corefcn/ls-mat-subsys.cc:342:29: warning: cast from 'const
octave_int<unsigned char>*' to 'const uint32_t*' {aka 'const unsigned int*'}
increases required alignment of target type [-Wcast-align]
  342 |       m_region_offsets[i] = reinterpret_cast<const uint32_t&>
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  343 |                               (fwrap_metadata_array(8 + i * 4));
      |                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../libinterp/corefcn/ls-mat-subsys.cc:388:22: warning: cast from 'const
octave_int<unsigned char>*' to 'const uint32_t*' {aka 'const unsigned int*'}
increases required alignment of target type [-Wcast-align]
  388 |       uint32_t val = reinterpret_cast<const uint32_t&>
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  389 |                        (fwrap_metadata_array(m_region_offsets[0] + i *
4));
      |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../libinterp/corefcn/ls-mat-subsys.cc:401:22: warning: cast from 'const
octave_int<unsigned char>*' to 'const uint32_t*' {aka 'const unsigned int*'}
increases required alignment of target type [-Wcast-align]
  401 |       uint32_t val = reinterpret_cast<const uint32_t&>
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  402 |                        (fwrap_metadata_array(m_region_offsets[2] + i *
4));
      |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../libinterp/corefcn/ls-mat-subsys.cc:414:22: warning: cast from 'const
octave_int<unsigned char>*' to 'const uint32_t*' {aka 'const unsigned int*'}
increases required alignment of target type [-Wcast-align]
  414 |       uint32_t val = reinterpret_cast<const uint32_t&>
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  415 |                        (fwrap_metadata_array(m_region_offsets[3] + i *
4));
      |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../libinterp/corefcn/ls-mat-subsys.cc:427:22: warning: cast from 'const
octave_int<unsigned char>*' to 'const uint32_t*' {aka 'const unsigned int*'}
increases required alignment of target type [-Wcast-align]
  427 |       uint32_t val = reinterpret_cast<const uint32_t&>
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  428 |                        (fwrap_metadata_array(m_region_offsets[1] + i *
4));
      |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../libinterp/corefcn/ls-mat-subsys.cc:440:22: warning: cast from 'const
octave_int<unsigned char>*' to 'const uint32_t*' {aka 'const unsigned int*'}
increases required alignment of target type [-Wcast-align]
  440 |       uint32_t val = reinterpret_cast<const uint32_t&>
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  441 |                        (fwrap_metadata_array(m_region_offsets[4] + i *
4));
      |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../libinterp/corefcn/ls-mat-subsys.cc: In member function 'octave_map
octave::subsystem_handler::get_object_properties(uint32_t, uint32_t, bool,
bool)':
../libinterp/corefcn/ls-mat-subsys.cc:503:51: warning: comparison of integer
expressions of different signedness: 'octave_idx_type' {aka 'int'} and 'const
uint32_t' {aka 'const unsigned int'} [-Wsign-compare]
  503 |   for (octave_idx_type current_id = 0; current_id < obj_type_id;
current_id++)
      |                                        ~~~~~~~~~~~^~~~~~~~~~~~~
../libinterp/corefcn/ls-mat-subsys.cc:521:33: warning: comparison of integer
expressions of different signedness: 'octave_idx_type' {aka 'int'} and
'uint32_t' {aka 'unsigned int'} [-Wsign-compare]
  521 |   for (octave_idx_type i = 0; i < nprops && ptr + 2 < end_ptr; i++)
      |                               ~~^~~~~~~~
../libinterp/corefcn/ls-mat-subsys.cc: In member function 'uint32_t
octave::subsystem_handler::get_name_index(const std::string&)':
../libinterp/corefcn/ls-mat-subsys.cc:622:26: warning: comparison of integer
expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and
'octave_idx_type' {aka 'int'} [-Wsign-compare]
  622 |   for (uint32_t i = 0; i < m_prop_class_names.numel (); i++)
      |                        ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../libinterp/corefcn/ls-mat-subsys.cc: In member function 'void
octave::subsystem_handler::process_object_properties(const
std::vector<std::tuple<octave_map, unsigned int, bool> >&, const
std::vector<bool>&, uint32_t)':
../libinterp/corefcn/ls-mat-subsys.cc:750:55: warning: comparison of integer
expressions of different signedness: 'octave_idx_type' {aka 'int'} and
'uint32_t' {aka 'unsigned int'} [-Wsign-compare]
  750 |           for (octave_idx_type prop_idx = 0; prop_idx < num_props;
prop_idx++)
      |                                              ~~~~~~~~~^~~~~~~~~~~


When building for targets with 32-bit pointers, `octave_idx_type` is a signed
32-bit integer. Casting `octave_idx_type` to or from 32-bit unsigned integers
can lead to integer overflow errors.

Are the integers in the -v7 files really unsigned? I seem to recall that
saving in that file format is limited to 2 GB (not 4 GB).



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?45833>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCaYYSPQAKCRCqLAuaBUf3
TvYhAQC5XG/p40SBe+J7VcmM7+owWKhyfq3gEqCfPhnGoPXs2AD8CJ/Y0sj5sGGW
qZUsdGp+qPIM6oSNjeCHn2lCQ4OLaQA=
=8iCh
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.