utfcpp icon indicating copy to clipboard operation
utfcpp copied to clipboard

Warnings from -Wsign-conversion on Gcc 11.4.0 with C++ 20

Open benblan opened this issue 9 months ago • 3 comments

Hello,

when I include the library (v4.0.5) in my code, I get the 2 following warnings. Not sure it comes from my code. Maybe the way I include it?

/home/project/extern/utfcpp/utf8/core.h: In instantiation of ‘utf8::internal::utf_error utf8::internal::get_sequence_4(octet_iterator&, octet_iterator, utf8::utfchar32_t&) [with octet_iterator = const char*; utf8::utfchar32_t = char32_t]’:
/home/project/extern/utfcpp/utf8/core.h:277:53:   required from ‘utf8::internal::utf_error utf8::internal::validate_next(octet_iterator&, octet_iterator, utf8::utfchar32_t&) [with octet_iterator = const char*; utf8::utfchar32_t = char32_t]’
/home/project/extern/utfcpp/utf8/core.h:305:45:   required from ‘utf8::internal::utf_error utf8::internal::validate_next(octet_iterator&, octet_iterator) [with octet_iterator = const char*]’
/home/project/extern/utfcpp/utf8/core.h:437:79:   required from ‘octet_iterator utf8::find_invalid(octet_iterator, octet_iterator) [with octet_iterator = const char*]’
/home/project/extern/utfcpp/utf8/core.h:447:28:   required from here
/home/project/extern/utfcpp/utf8/core.h:237:20: warning: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion]
  237 |         code_point += (utf8::internal::mask8(*it) << 6) & 0xfff;
      |         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/project/extern/utfcpp/utf8/core.h: In instantiation of ‘utf8::internal::utf_error utf8::internal::get_sequence_3(octet_iterator&, octet_iterator, utf8::utfchar32_t&) [with octet_iterator = __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >; utf8::utfchar32_t = char32_t]’:
/home/project/extern/utfcpp/utf8/core.h:274:53:   required from ‘utf8::internal::utf_error utf8::internal::validate_next(octet_iterator&, octet_iterator, utf8::utfchar32_t&) [with octet_iterator = __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >; utf8::utfchar32_t = char32_t]’
/home/project/extern/utfcpp/utf8/core.h:305:45:   required from ‘utf8::internal::utf_error utf8::internal::validate_next(octet_iterator&, octet_iterator) [with octet_iterator = __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >]’
/home/project/extern/utfcpp/utf8/core.h:437:79:   required from ‘octet_iterator utf8::find_invalid(octet_iterator, octet_iterator) [with octet_iterator = __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >]’
/home/project/extern/utfcpp/utf8/core.h:452:59:   required from here
/home/project/extern/utfcpp/utf8/core.h:218:20: warning: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion]
  218 |         code_point += (*it) & 0x3f;
      |         ~~~~~~~~~~~^~~~~~~~~~~~~~~

benblan avatar May 19 '24 21:05 benblan