Kleiner Hinweis: C++ strings+ neues tumbleweed --> neuer g++: type cast nötig

Heute habe ich Tumbleweed upgedatet.
Riesenschreck, als ich mein C+±Programm übersetzen wollte: seitenlange Fehlermeldungen!
Habe den Fehler bei meinen letzten Änderungen gesucht …

Der Grund simpel: der neue G++ (egal, ob G+±6 oder G+±7) kennt 128-bit Integers, und Stringroutinen wie str.find_first_of geben offenbar keine für den Compiler erkennbare size-Angabe zurück.
Keine Ahnung, ob das dem Standard entspricht oder ein Fehler in der Library ist.
Nötig z.B.:

t = abs( static_cast<long>(str.find_first_of(" ,",i+1)) );
// statt bisher:
//  t = abs( str.find_first_of(" ,",i+1));
 

Ohne den Cast produziert jede derartige Stelle eine Fehlerausgabe der Art (hier mit g+±7):


it.h: In member function ‘Params<word> Params<word>::operator+=(const string&)’:
it.h:514:44: error: call of overloaded ‘abs(std::__cxx11::basic_string<char>::size_type)’ is ambiguous
       t = abs( str.find_first_of(" ,",i+1) ); str.find_first_not_of(' ',t+1);
                                            ^
In file included from /usr/include/c++/7/cstdlib:75:0,
                 from /usr/include/c++/7/ext/string_conversions.h:41,
                 from /usr/include/c++/7/bits/basic_string.h:6159,
                 from /usr/include/c++/7/string:52,
                 from it.h:53,
                 from it.cc:26:
/usr/include/stdlib.h:751:12: note: candidate: int abs(int)
 extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
            ^~~
In file included from /usr/include/c++/7/cstdlib:77:0,
                 from /usr/include/c++/7/ext/string_conversions.h:41,
                 from /usr/include/c++/7/bits/basic_string.h:6159,
                 from /usr/include/c++/7/string:52,
                 from it.h:53,
                 from it.cc:26:
/usr/include/c++/7/bits/std_abs.h:56:3: note: candidate: long int std::abs(long int)
   abs(long __i) { return __builtin_labs(__i); }
   ^~~
/usr/include/c++/7/bits/std_abs.h:61:3: note: candidate: long long int std::abs(long long int)
   abs(long long __x) { return __builtin_llabs (__x); }
   ^~~
/usr/include/c++/7/bits/std_abs.h:70:3: note: candidate: constexpr double std::abs(double)
   abs(double __x)
   ^~~
/usr/include/c++/7/bits/std_abs.h:74:3: note: candidate: constexpr float std::abs(float)
   abs(float __x)
   ^~~
/usr/include/c++/7/bits/std_abs.h:78:3: note: candidate: constexpr long double std::abs(long double)
   abs(long double __x)
   ^~~
/usr/include/c++/7/bits/std_abs.h:84:3: note: candidate: constexpr __int128 std::abs(__int128)
   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
   ^~~
/usr/include/c++/7/bits/std_abs.h:102:3: note: candidate: constexpr __float128 std::abs(__float128)
   abs(__float128 __x)
   ^~~
In file included from PolyTemplate.h:48:0,
                 from it.h:346,
                 from it.cc:26:
Interval.h:323:17: note: candidate: Interval abs(const Interval&)
 inline Interval abs(const Interval& y) {
                 ^~~

C++ ist und bleibt eben eine krasse Makroassemblersprache …

find_first_of returniert size_t , das ist sowieso immer unsigned, also null oder größer null,
den Retur-Wert von find_first_of noch mal mit abs positiv zu machen ist unnötig,
Wenn du den Wert jedoch als integer , mit Vorzeichen, weiter verwenden möchtest solltest du prüfen das Wert kleiner als max integer ist.
(was du auch bei abs machen müsstest da dein Program ansonst undefiniertes Verhalten hat in dem Fall das der an abs gegebene Wert zu groß ist)