# HG changeset patch # User Mike Miller # Date 1455047642 28800 # Node ID b48d65c5df5be06fc50c038739cf7cca9c6cbf18 # Parent 6b0ded11d7087822702146919216c74feadf5991 Disable char/int8_t function overloads where not permitted (bug #45411) * configure.ac (HAVE_OVERLOAD_CHAR_INT8_TYPES): Add test and conditional on whether the system allows overloads with char, int8_t, and uint8_t (e.g. Solaris does not). * oct_inttypes.h, oct-stream.cc: Use HAVE_OVERLOAD_CHAR_INT8_TYPES. diff -r 6b0ded11d708 -r b48d65c5df5b configure.ac --- a/configure.ac Tue Feb 09 10:34:35 2016 -0800 +++ b/configure.ac Tue Feb 09 11:54:02 2016 -0800 @@ -2222,6 +2222,25 @@ AC_STRUCT_TIMEZONE +## Check if C++ compiler allows overload of char, int8_t, and uint8_t. +AC_CACHE_CHECK([whether ${CXX-g++} allows overload of char, int8_t, and uint8_t], + [octave_cv_overload_char_int8_t], + [AC_LANG_PUSH(C++) + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ + #include + void somefunc(char x) {}; + void somefunc(int8_t x) {}; + void somefunc(uint8_t x) {}; + ]])], + octave_cv_overload_char_int8_t=yes, + octave_cv_overload_char_int8_t=no) + AC_LANG_POP(C++) + ]) +if test $octave_cv_overload_char_int8_t = yes; then + AC_DEFINE(HAVE_OVERLOAD_CHAR_INT8_TYPES, 1, + [Define to 1 if C++ allows overload of char, int8_t, and uint8_t types.]) +fi + ### Check compiler characteristics. ## Does compiler have support for new friend template declarations? diff -r 6b0ded11d708 -r b48d65c5df5b libinterp/corefcn/oct-stream.cc --- a/libinterp/corefcn/oct-stream.cc Tue Feb 09 10:34:35 2016 -0800 +++ b/libinterp/corefcn/oct-stream.cc Tue Feb 09 11:54:02 2016 -0800 @@ -3884,7 +3884,9 @@ INSTANTIATE_WRITE (int64_t); INSTANTIATE_WRITE (uint64_t); INSTANTIATE_WRITE (bool); +#if defined (HAVE_OVERLOAD_CHAR_INT8_TYPES) INSTANTIATE_WRITE (char); +#endif INSTANTIATE_WRITE (float); INSTANTIATE_WRITE (double); diff -r 6b0ded11d708 -r b48d65c5df5b liboctave/util/oct-inttypes.h --- a/liboctave/util/oct-inttypes.h Tue Feb 09 10:34:35 2016 -0800 +++ b/liboctave/util/oct-inttypes.h Tue Feb 09 11:54:02 2016 -0800 @@ -837,10 +837,12 @@ octave_int (T i) : ival (i) { } +#if defined (HAVE_OVERLOAD_CHAR_INT8_TYPES) // Always treat characters as unsigned. octave_int (char c) : ival (octave_int_base::truncate_int (static_cast (c))) { } +#endif octave_int (double d) : ival (octave_int_base::convert_real (d)) { }