Cast char to signed to avoid type-limits warning (courtesy gsl-lite i… · martinmoene/lest@24ebadc (original) (raw)

2 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -559,7 +559,7 @@ inline std::string transformed( char chr )
559 559 return tr.str;
560 560 }
561 561
562 -auto unprintable = [](char c){ return 0 <= c && c < ' '; };
562 +auto unprintable = [](char c){ return 0 <= static_cast<signed char>(c) && c < ' '; }; // the cast is necessary on architectures where char is unsigned
563 563
564 564 auto to_hex_string = [](char c)
565 565 {
Original file line number Diff line number Diff line change
@@ -614,7 +614,7 @@ inline void inform( location where, text expr )
614 614
615 615 // Expression decomposition:
616 616
617 -inline bool unprintable( char c ) { return 0 <= c && c < ' '; }
617 +inline bool unprintable( char c ) { return 0 <= static_cast<signed char>(c) && c < ' '; } // the cast is necessary on architectures where char is unsigned
618 618
619 619 inline std::string to_hex_string(char c)
620 620 {