bugGNU Octave - Bugs: bug #45411, ...

 
 

bug #45411: octave_int<T>::octave_int(char) is invalid on Sparc Solaris

Submitter:  Tatsuro MATSUOKA <tmacchant>
Submitted:  Fri 26 Jun 2015 02:53:02 AM UTC
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Build Failure
Status:  Fixed Assigned to:  None
Originator Name:  Tatsuro MATUOKA Open/Closed:  * Closed
Release:  * 4.0.0 Operating System:  * Solaris/SunOS
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

( Jump to the original submission )

Tue 09 Feb 2016 07:57:52 PM UTC, comment #11: 

Done on stable, apologies to all for the delay.

http://hg.savannah.gnu.org/hgweb/octave/rev/b48d65c5df5b

I can't remember if gnulib has been updated on the stable branch, but this change along with http://hg.savannah.gnu.org/hgweb/octave/rev/375cea8d4135 and an updated gnulib should allow the upcoming 4.0.1 to build on Solaris.

Mike Miller <mtmiller>
Project Administrator
Thu 04 Feb 2016 10:32:49 PM UTC, comment #10: 

Seems fine to me.

John W. Eaton <jwe>
Project Administrator
Thu 04 Feb 2016 09:58:48 PM UTC, comment #9: 

Any objections to the following change on the stable branch? I have tested this patch against 4.0.0 on Solaris (where the patch fixes compilation error), on Linux (where the patch has no effect), and on Linux with a modified stdint.h (where the patch fixes the same compilation error as on Solaris). It would be nice to get this fixed in 4.0.1.

(file #36248)

Mike Miller <mtmiller>
Project Administrator
Sat 08 Aug 2015 03:28:48 PM UTC, comment #8: 

Attaching a patch that allows Octave 4.0.0 to build completely on Solaris. The first hunk of the patch is a change that's already been made in gnulib but not merged into Octave yet (http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=d6176702c3ffb6c56e6620397470e1b3bd540b10). The second two can be improved by adding configure tests to detect whether the system allows char to overload int8_t.

(file #34597)

Mike Miller <mtmiller>
Project Administrator
Mon 03 Aug 2015 05:10:33 PM UTC, comment #7: 

I am working with the original reporter of this problem (Tatsuro, no more need to copy messages back and forth, but thanks for your help so far!) I can confirm that this function overload is invalid because of what I suspected, that on Sparc Solaris the int8_t is defined to be "char" instead of "signed char". On Linux, both are signed, but they are distinct types in the C++ language so they can be safely overloaded.

The quickest way I can see around this is to not compile that particular overload.

This particular overload was added to fix bug #42054 (see changeset http://hg.savannah.gnu.org/hgweb/octave/rev/37c300acfcfd). Is there a different way to solve the original problem without this problematic overload?

Updating bug meta info.

Mike Miller <mtmiller>
Project Administrator
Sun 26 Jul 2015 02:38:31 AM UTC, comment #6: 

The signed vs. unsigned 8-bit type sounds about right.  Can't think of any simple approach because there appears to be a lot going on with regard to the definition.  In particular, these lines:

libgnu/stdint.in.h:   files, so that we can "#define int8_t signed char" below without
libgnu/stdint.in.h:   signed char int8_t;" that will get messed up by our macro.  Our
libgnu/stdint.in.h:#undef int8_t
libgnu/stdint.in.h:#undef uint8_t
libgnu/stdint.in.h:typedef signed char gl_int8_t;
libgnu/stdint.in.h:typedef unsigned char gl_uint8_t;
libgnu/stdint.in.h:#define int8_t gl_int8_t
libgnu/stdint.in.h:#define uint8_t gl_uint8_t
libgnu/stdint.in.h:#define int_least8_t int8_t
libgnu/stdint.in.h:#define uint_least8_t uint8_t

mess around with the definitions of int8_t and uint8_t.  Octave seems to be assuming int8_t is signed, so if int8_t is undefined and some how redefined with a "signed" qualifier it might be fine in terms of Octave's mathematical treatment of related variable types.

Dan Sebald <sebald>
Sat 11 Jul 2015 11:30:22 PM UTC, comment #5: 

This error seems to be because Solaris system headers define int8_t as "typedef char int8_t", while Linux uses "typedef signed char int8_t". This means in Linux we have distinct overloads for octave_int<int8_t> but in Solaris they are not distinct.

Probably needs a new configure test and a conditional compile to get around this, anyone other ideas?

Mike Miller <mtmiller>
Project Administrator
Sat 11 Jul 2015 07:42:11 AM UTC, comment #4: 

Other person (handle name ccj4467) gives us error message for octave-4.0.0 on the octave ML.

http://octave.1599824.n4.nabble.com/Compile-error-at-compiling-liboctave-array-Array-b-cc-due-to-cannot-be-overloaded-octave-int-char-c-tp4671122p4671544.html

make[3]: Entering directory '/work/cjohnson/octave-4.0.0/liboctave'
  CXX      array/array_libarray_la-Array-b.lo
In file included from array/idx-vector.h:36:0,
                 from array/Array.h:36,
                 from array/Array-b.cc:29:
./util/oct-inttypes.h: In instantiation of 'class octave_int<char>':
./util/oct-inttypes.h:1048:31:   required from here
./util/oct-inttypes.h:841:3: error: 'octave_int<T>::octave_int(char) [with T = char]' cannot be overloaded
   octave_int (char c)
   ^
./util/oct-inttypes.h:838:3: error: with 'octave_int<T>::octave_int(T) [with T = char]'
   octave_int (T i) : ival (i) { }
   ^
Makefile:6887: recipe for target 'array/array_libarray_la-Array-b.lo' failed
make[3]: *** [array/array_libarray_la-Array-b.lo] Error 1
make[3]: Leaving directory '/work/cjohnson/octave-4.0.0/liboctave'
Makefile:4057: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/work/cjohnson/octave-4.0.0/liboctave'
Makefile:2122: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/work/cjohnson/octave-4.0.0'
Makefile:1985: recipe for target 'all' failed
make: *** [all] Error 2

seems to be the same as those on 3.8.2.

Tatsuro MATSUOKA <tmacchant>
Fri 26 Jun 2015 09:15:10 PM UTC, comment #3: 

Michele

Could you give us the screen output for 4.0.0 during gmake?

Tatsuro MATSUOKA <tmacchant>
Fri 26 Jun 2015 06:12:43 PM UTC, comment #2: 

The original mailing list thread said and comment #0 below both said that building both 3.8.2 and 4.0.0 resulted in the same error, can't confirm but retagging.

Mike Miller <mtmiller>
Project Administrator
Fri 26 Jun 2015 03:41:11 PM UTC, comment #1: 

The same error may result, but can the original reporter verify this with the 4.0.0 code?  The 3.8.2 version of Octave is unsupported and I don't want to bother with something that may have been fixed, or where the line numbers of the error messages could be totally different.

Rik <rik5>
Project Administrator
Fri 26 Jun 2015 02:53:02 AM UTC, original submission:  

This is originally discussed at
http://octave.1599824.n4.nabble.com/Compile-error-at-compiling-liboctave-array-Array-b-cc-due-to-quot-cannot-be-overloaded-octave-int-ch-td4671122.html

by Michele31415.

*********************
The environments etcs. 
 Sparc Solaris , gcc-4.9.2
 Octave 3.8.2 (4.0.0 may give the same error)

Compiling source file: liboctave/array/Array-b.cc
Place error occurred:  liboctave/util/oct-inttypes.h

Error message:

 

./util/oct-inttypes.h: In instantiation of 'class octave_int<char>': ./util/oct-inttypes.h:1041:31:   required from here
./util/oct-inttypes.h:834:3: error: 'octave_int<T>::octave_int(char) [with T = char]' cannot be overloaded
   octave_int (char c)
   ^
./util/oct-inttypes.h:831:3: error: with 'octave_int<T>::octave_int(T) [with T = char]'
   octave_int (T i) : ival (i) { }
   ^

Daniel Sebald's assumption
 To me, that sounds like attempting to convert 8-bit integer
 behavior to 16-bit integer so that the << operators output numbers.
 Somehow this sort of trick (for lack of word) isn't compiling   
 correctly on SPARC.

Mike Muller
 Yes I think so. Unfortunately this also needs someone with access
 to a SPARC Solaris system with GNU tools to reproduce and provide a
 fix. Notably we don't see this error when building Octave on a
 SPARC with Debian GNU/Linux [1].

 [1] https://buildd.debian.org/status/logs.php?pkg=octave&ver=3.8.2-4&arch=sparc

Source of oct-inttypes.h of octave-3.8.2 is attached.

Short log ans short source on this matter

array/Array-b.cc:29
#include "Array.h"

array/Array.h:36
#include "idx-vector.h"

array/idx-vector.h:35
#include "oct-inttypes.h"

./util/oct-inttypes.h: In instantiation of 'class octave_int<char>':
./util/oct-inttypes.h:1041:31:   required from here
./util/oct-inttypes.h:834:3: error: 'octave_int<T>::octave_int(char) [with T = char]' cannot be overloaded    octave_int (char c)
   ^
./util/oct-inttypes.h:1041
1037: template <>
1038: inline std::ostream&
1039: operator << (std::ostream& os, const octave_int<int8_t>& ival)
1040: {
1041:   os << static_cast<int> (ival.value ());
1042:   return os;
1043: }

./util/oct-inttypes.h:834

833:   // Always treat characters as unsigned.
834:   octave_int (char c)
835:    : ival (octave_int_base<T>::truncate_int (static_cast<unsigned char> (c)))
836:   { }

./util/oct-inttypes.h:831:3: error: with 'octave_int<T>::octave_int(T) [with T = char]'
   octave_int (T i) : ival (i) { }
   ^
./util/oct-inttypes.h:831

831:   octave_int (T i) : ival (i) { }

Full log for errors (and warnings)

 In file included from array/idx-vector.h:35:0,
                 from array/Array.h:36,
                 from array/Array-b.cc:29:
./util/oct-inttypes.h: In instantiation of 'class octave_int<char>':
./util/oct-inttypes.h:1041:31:   required from here
./util/oct-inttypes.h:834:3: error: 'octave_int<T>::octave_int(char) [with T = char]' cannot be overloaded
   octave_int (char c)
   ^
./util/oct-inttypes.h:831:3: error: with 'octave_int<T>::octave_int(T) [with T = char]'
   octave_int (T i) : ival (i) { }
   ^
In file included from array/idx-vector.h:37:0,
                 from array/Array.h:36,
                 from array/Array-b.cc:29:
./util/oct-mem.h: In function 'T* no_ctor_new(std::size_t) [with T = std::complex<double>; std::size_t = unsigned int]':
./util/oct-mem.h:143:74: warning: cast from 'char*' to 'Complex* {aka std::complex<double>*}' increases required alignment of target type [-Wcast-align]
 { return reinterpret_cast<T *> (new char [safe_size_comp (n, sizeof (T))]); } \                                                                          ^
./util/oct-mem.h:148:1: note: in expansion of macro 'DEFINE_POD_NEW_DELETE'
 DEFINE_POD_NEW_DELETE (Complex)
 ^
./util/oct-mem.h: In function 'T* no_ctor_new(std::size_t) [with T = std::complex<float>; std::size_t = unsigned int]':
./util/oct-mem.h:143:74: warning: cast from 'char*' to 'FloatComplex* {aka std::complex<float>*}' increases required alignment of target type [-Wcast-align]
 { return reinterpret_cast<T *> (new char [safe_size_comp (n, sizeof (T))]); } \                                                                          ^
./util/oct-mem.h:149:1: note: in expansion of macro 'DEFINE_POD_NEW_DELETE'
 DEFINE_POD_NEW_DELETE (FloatComplex)
 ^
./util/oct-mem.h: In function 'T* no_ctor_new(std::size_t) [with T = octave_int<short int>; std::size_t = unsigned int]':
./util/oct-mem.h:143:74: warning: cast from 'char*' to 'octave_int16* {aka octave_int<short int>*}' increases required alignment of target type [-Wcast-align]
 { return reinterpret_cast<T *> (new char [safe_size_comp (n, sizeof (T))]); } \                                                                          ^
./util/oct-mem.h:152:1: note: in expansion of macro 'DEFINE_POD_NEW_DELETE'
 DEFINE_POD_NEW_DELETE (octave_int16)
 ^
./util/oct-mem.h: In function 'T* no_ctor_new(std::size_t) [with T = octave_int<int>; std::size_t = unsigned int]':
./util/oct-mem.h:143:74: warning: cast from 'char*' to 'octave_int32* {aka octave_int<int>*}' increases required alignment of target type [-Wcast-align]
 { return reinterpret_cast<T *> (new char [safe_size_comp (n, sizeof (T))]); } \                                                                          ^
./util/oct-mem.h:153:1: note: in expansion of macro 'DEFINE_POD_NEW_DELETE'
 DEFINE_POD_NEW_DELETE (octave_int32)
 ^
./util/oct-mem.h: In function 'T* no_ctor_new(std::size_t) [with T = octave_int<long long int>; std::size_t = unsigned int]':
./util/oct-mem.h:143:74: warning: cast from 'char*' to 'octave_int64* {aka octave_int<long long int>*}' increases required alignment of target type [-Wcast-align]
 { return reinterpret_cast<T *> (new char [safe_size_comp (n, sizeof (T))]); } \                                                                          ^
./util/oct-mem.h:154:1: note: in expansion of macro 'DEFINE_POD_NEW_DELETE'
 DEFINE_POD_NEW_DELETE (octave_int64)
 ^
./util/oct-mem.h: In function 'T* no_ctor_new(std::size_t) [with T = octave_int<short unsigned int>; std::size_t = unsigned int]':
./util/oct-mem.h:143:74: warning: cast from 'char*' to 'octave_uint16* {aka octave_int<short unsigned int>*}' increases required alignment of target type [-Wcast-align]
 { return reinterpret_cast<T *> (new char [safe_size_comp (n, sizeof (T))]); } \                                                                          ^
./util/oct-mem.h:156:1: note: in expansion of macro 'DEFINE_POD_NEW_DELETE'
 DEFINE_POD_NEW_DELETE (octave_uint16)
 ^
./util/oct-mem.h: In function 'T* no_ctor_new(std::size_t) [with T = octave_int<unsigned int>; std::size_t = unsigned int]':
./util/oct-mem.h:143:74: warning: cast from 'char*' to 'octave_uint32* {aka octave_int<unsigned int>*}' increases required alignment of target type [-Wcast-align]
 { return reinterpret_cast<T *> (new char [safe_size_comp (n, sizeof (T))]); } \                                                                          ^
./util/oct-mem.h:157:1: note: in expansion of macro 'DEFINE_POD_NEW_DELETE'
 DEFINE_POD_NEW_DELETE (octave_uint32)
 ^
./util/oct-mem.h: In function 'T* no_ctor_new(std::size_t) [with T = octave_int<long long unsigned int>; std::size_t = unsigned int]':
./util/oct-mem.h:143:74: warning: cast from 'char*' to 'octave_uint64* {aka octave_int<long long unsigned int>*}' increases required alignment of target type [-Wcast-align]
 { return reinterpret_cast<T *> (new char [safe_size_comp (n, sizeof (T))]); } \                                                                          ^
./util/oct-mem.h:158:1: note: in expansion of macro 'DEFINE_POD_NEW_DELETE'
 DEFINE_POD_NEW_DELETE (octave_uint64)
 ^
In file included from array/Array.cc:42:0,
                 from array/Array-b.cc:30:
./util/oct-locbuf.h: In member function 'octave_local_buffer<short unsigned int>::operator short unsigned int*() const':
./util/oct-locbuf.h:120:51: warning: cast from 'char*' to 'short unsigned int*' increases required alignment of target type [-Wcast-align]
     return reinterpret_cast<TYPE *> (this->data ()); \
                                                   ^
./util/oct-locbuf.h:126:1: note: in expansion of macro 'SPECIALIZE_POD_BUFFER'
 SPECIALIZE_POD_BUFFER (unsigned short);
 ^
./util/oct-locbuf.h: In member function 'octave_local_buffer<short int>::operator short int*() const':
./util/oct-locbuf.h:120:51: warning: cast from 'char*' to 'short int*' increases required alignment of target type [-Wcast-align]
     return reinterpret_cast<TYPE *> (this->data ()); \
                                                   ^
./util/oct-locbuf.h:127:1: note: in expansion of macro 'SPECIALIZE_POD_BUFFER'
 SPECIALIZE_POD_BUFFER (short);
 ^
./util/oct-locbuf.h: In member function 'octave_local_buffer<int>::operator int*() const':
./util/oct-locbuf.h:120:51: warning: cast from 'char*' to 'int*' increases required alignment of target type [-Wcast-align]
     return reinterpret_cast<TYPE *> (this->data ()); \
                                                   ^
./util/oct-locbuf.h:128:1: note: in expansion of macro 'SPECIALIZE_POD_BUFFER'
 SPECIALIZE_POD_BUFFER (int);
 ^
./util/oct-locbuf.h: In member function 'octave_local_buffer<unsigned int>::operator unsigned int*() const':
./util/oct-locbuf.h:120:51: warning: cast from 'char*' to 'unsigned int*' increases required alignment of target type [-Wcast-align]
     return reinterpret_cast<TYPE *> (this->data ()); \
                                                   ^
./util/oct-locbuf.h:129:1: note: in expansion of macro 'SPECIALIZE_POD_BUFFER'
 SPECIALIZE_POD_BUFFER (unsigned int);
 ^
./util/oct-locbuf.h: In member function 'octave_local_buffer<long int>::operator long int*() const':
./util/oct-locbuf.h:120:51: warning: cast from 'char*' to 'long int*' increases required alignment of target type [-Wcast-align]
     return reinterpret_cast<TYPE *> (this->data ()); \
                                                   ^
./util/oct-locbuf.h:130:1: note: in expansion of macro 'SPECIALIZE_POD_BUFFER'
 SPECIALIZE_POD_BUFFER (long);
 ^
./util/oct-locbuf.h: In member function 'octave_local_buffer<long unsigned int>::operator long unsigned int*() const':
./util/oct-locbuf.h:120:51: warning: cast from 'char*' to 'long unsigned int*' increases required alignment of target type [-Wcast-align]
     return reinterpret_cast<TYPE *> (this->data ()); \
                                                   ^
./util/oct-locbuf.h:131:1: note: in expansion of macro 'SPECIALIZE_POD_BUFFER'
 SPECIALIZE_POD_BUFFER (unsigned long);
 ^
./util/oct-locbuf.h: In member function 'octave_local_buffer<float>::operator float*() const':
./util/oct-locbuf.h:120:51: warning: cast from 'char*' to 'float*' increases required alignment of target type [-Wcast-align]
     return reinterpret_cast<TYPE *> (this->data ()); \
                                                   ^
./util/oct-locbuf.h:132:1: note: in expansion of macro 'SPECIALIZE_POD_BUFFER'
 SPECIALIZE_POD_BUFFER (float);
 ^
./util/oct-locbuf.h: In member function 'octave_local_buffer<double>::operator double*() const':
./util/oct-locbuf.h:120:51: warning: cast from 'char*' to 'double*' increases required alignment of target type [-Wcast-align]
     return reinterpret_cast<TYPE *> (this->data ()); \
                                                   ^
./util/oct-locbuf.h:133:1: note: in expansion of macro 'SPECIALIZE_POD_BUFFER'
 SPECIALIZE_POD_BUFFER (double);
 ^
./util/oct-locbuf.h: In member function 'octave_local_buffer<std::complex<double> >::operator Complex*() const':
./util/oct-locbuf.h:120:51: warning: cast from 'char*' to 'Complex* {aka std::complex<double>*}' increases required alignment of target type [-Wcast-align]
     return reinterpret_cast<TYPE *> (this->data ()); \
                                                   ^
./util/oct-locbuf.h:135:1: note: in expansion of macro 'SPECIALIZE_POD_BUFFER'
 SPECIALIZE_POD_BUFFER (Complex);
 ^
./util/oct-locbuf.h: In member function 'octave_local_buffer<std::complex<float> >::operator FloatComplex*() const':
./util/oct-locbuf.h:120:51: warning: cast from 'char*' to 'FloatComplex* {aka std::complex<float>*}' increases required alignment of target type [-Wcast-align]
     return reinterpret_cast<TYPE *> (this->data ()); \
                                                   ^
./util/oct-locbuf.h:136:1: note: in expansion of macro 'SPECIALIZE_POD_BUFFER'
 SPECIALIZE_POD_BUFFER (FloatComplex);
 ^
Makefile:5264: recipe for target 'array/array_libarray_la-Array-b.lo' failed
gmake[4]: *** [array/array_libarray_la-Array-b.lo] Error 1

Tatsuro MATSUOKA <tmacchant>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #36248:  oct-sol.diff added by mtmiller (2KiB - text/x-diff)
file #34321:  oct-inttypes.h added by tmacchant (34KiB - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by sebald (Posted a comment)
  • -email is unavailable- added by tmacchant (Submitted the item)
  • -email is unavailable- added by tmacchant
  • -email is unavailable- added by tmacchant
  • -email is unavailable- added by tmacchant
  • -email is unavailable- added by tmacchant
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.

     

     

     

     

    Follow 20 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-02-22 mtmiller Carbon-CopyRemoved -email is unavailable- -
    2019-02-22 mtmiller Carbon-CopyRemoved 80942 -
    2016-02-09 mtmiller StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2016-02-04 mtmiller Attached File- Added oct-sol.diff, #36248
    2015-08-08 mtmiller Attached File- Added octave-4.0.0-solaris-gcc49.patch, #34597
    2015-08-03 mtmiller CategoryConfiguration and Build System Libraries
        StatusNeed Info Confirmed
        Summarycast fail at liboctave/util/oct-inttypes.h on Sparc Solaris octave_int::octave_int(char) is invalid on Sparc Solaris
    2015-07-11 rik5 Carbon-CopyRemoved rik -
    2015-07-11 rik5 Carbon-CopyRemoved 72865 -
    2015-06-26 mtmiller StatusNone Need Info
        Release3.8.2 4.0.0
    2015-06-26 tmacchant Attached File- Added oct-inttypes.h, #34321
        Carbon-Copy- Added -email is unavailable-
        Carbon-Copy- Added daniel j sebald
        Carbon-Copy- Added rik
        Carbon-Copy- Added jwe
        Carbon-Copy- Added jordi
        Carbon-Copy- Added michele31415

    Back to the top


    Powered by Savane 3.9